Skip to content

Commit

Permalink
Bigger test for test_primality, which would have caught bug in previo…
Browse files Browse the repository at this point in the history
…us commit; introduced DEGBOUNDs parameter for package.
  • Loading branch information
GDeLaurentis committed Dec 17, 2024
1 parent 2a4d20e commit cd2aa50
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions syngular/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion syngular/ideal_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 17 additions & 2 deletions tests/test_ideal_algorithms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import syngular

from syngular import Ideal, Ring
from syngular.ideal_algorithms import Inconclusive
Expand All @@ -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
Expand All @@ -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)

0 comments on commit cd2aa50

Please sign in to comment.