From cd2aa50b263e9ed902cbc013c60e1f6ad843a998 Mon Sep 17 00:00:00 2001 From: GDeLaurentis Date: Tue, 17 Dec 2024 13:55:23 +0000 Subject: [PATCH] Bigger test for test_primality, which would have caught bug in previous commit; introduced DEGBOUNDs parameter for package. --- syngular/__init__.py | 1 + syngular/ideal_algorithms.py | 2 +- tests/test_ideal_algorithms.py | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/syngular/__init__.py b/syngular/__init__.py index e7998e1..c1b67e7 100644 --- a/syngular/__init__.py +++ b/syngular/__init__.py @@ -1,5 +1,6 @@ TIMEOUT = 60 # seconds # noqa DEGBOUND = 0 # 0 = no-bound # noqa +DEGBOUNDs = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24] # noqa from .ideal import Ideal # noqa from .ring import Ring # noqa diff --git a/syngular/ideal_algorithms.py b/syngular/ideal_algorithms.py index 619cd10..3a012f8 100644 --- a/syngular/ideal_algorithms.py +++ b/syngular/ideal_algorithms.py @@ -216,7 +216,7 @@ def primeTestDLP(self, verbose=False, timeout_fpoly=10, timeout_dim=600, # Experimental - Assumes codim w/ deg bound <= true codim. # Helps termiante the prime test early, IF the result is True. - for deg_bound in [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24] * iterated_degbound_computation: + for deg_bound in syngular.DEGBOUNDs * iterated_degbound_computation: syngular.DEGBOUND = deg_bound X.delete_cached_properties() if self.codim < X.codim: diff --git a/tests/test_ideal_algorithms.py b/tests/test_ideal_algorithms.py index 50080dc..08603ad 100644 --- a/tests/test_ideal_algorithms.py +++ b/tests/test_ideal_algorithms.py @@ -1,4 +1,5 @@ import pytest +import syngular from syngular import Ideal, Ring from syngular.ideal_algorithms import Inconclusive @@ -16,7 +17,7 @@ def test_extension_contraction(): I.extension_contraction(U, ordering="Dp") == (1, J) -def test_primeTestDLP(): +def test_test_primality(): I = Ideal(Ring('0', ('x1', 'x2'), 'dp'), ['x1*x2']) J = Ideal(Ring('0', ('x1', 'x2'), 'dp'), ['x2']) assert I.test_primality(verbose=True) is False @@ -25,8 +26,22 @@ def test_primeTestDLP(): assert J.test_primality(verbose=True, iterated_degbound_computation=True) is True -def test_primeTestDLP_inconclusive(): +def test_test_primality_inconclusive(): I = Ideal(Ring('0', ('x1', 'x2'), 'dp'), ['x1^2']) with pytest.raises(Inconclusive): assert I.test_primality(verbose=True) is False assert I.test_primality(verbose=True, iterated_degbound_computation=True) is False + + +def test_test_primality_with_degree_bound(): + # from: LipsIdeal(6, ('⟨1|2+3|1]', '⟨2|1+4|2]')) + r = Ring(0, ('d6', 'c6', 'b6', 'a6', 'd5', 'c5', 'b5', 'a5', 'd4', 'c4', 'b4', 'a4', 'd3', 'c3', 'b3', 'a3', 'd2', 'c2', 'b2', 'a2', 'd1', 'c1', 'b1', 'a1'), 'dp') + generators = ['4*a1*b2*c1*d2 - 4*a1*b2*c2*d1 + 4*a1*b3*c1*d3 - 4*a1*b3*c3*d1 - 4*a2*b1*c1*d2 + 4*a2*b1*c2*d1 - 4*a3*b1*c1*d3 + 4*a3*b1*c3*d1', + '4*a1*b2*c1*d2 - 4*a1*b2*c2*d1 - 4*a2*b1*c1*d2 + 4*a2*b1*c2*d1 + 4*a2*b4*c2*d4 - 4*a2*b4*c4*d2 - 4*a4*b2*c2*d4 + 4*a4*b2*c4*d2', + 'b1*d1 + b2*d2 + b3*d3 + b4*d4 + b5*d5 + b6*d6', + '-a1*d1 - a2*d2 - a3*d3 - a4*d4 - a5*d5 - a6*d6', + '-b1*c1 - b2*c2 - b3*c3 - b4*c4 - b5*c5 - b6*c6', + 'a1*c1 + a2*c2 + a3*c3 + a4*c4 + a5*c5 + a6*c6'] + I = Ideal(r, generators) + syngular.DEGBOUNDs = [4, 6, ] + assert I.test_primality(verbose=True, iterated_degbound_computation=True, projection_number=192)