Skip to content

Commit 05ad57b

Browse files
author
Release Manager
committed
gh-36018: Fix tests with singular 4.3.2p4 Due to changes in the output of `hilb` in singular 4.3.2p4 (it now outputs a polynomial instead of a list of monomials and coefficients to debug), some tests are failing. Additionally, the problematic `hilbert_numerator` example now correctly throws an overflow error instead of giving a wrong answer. We mark it as `known bug` so the test passes with older versions of singular, the label can be removed once we require 4.3.2p4. URL: #36018 Reported by: Antonio Rojas Reviewer(s): Matthias Köppe
2 parents 72b41aa + 7caf95b commit 05ad57b

File tree

3 files changed

+22
-46
lines changed

3 files changed

+22
-46
lines changed

src/sage/interfaces/singular.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -604,24 +604,15 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
604604
sage: i = singular.ideal(['x^2','y^2','z^2'])
605605
sage: s = i.std()
606606
sage: singular.eval('hilb(%s)'%(s.name()))
607-
'// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
608-
3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
607+
'...// dimension (affine) = 0\n//
609608
degree (affine) = 8'
610609
611610
::
612611
613612
sage: from sage.misc.verbose import set_verbose
614613
sage: set_verbose(1)
615614
sage: o = singular.eval('hilb(%s)'%(s.name()))
616-
// 1 t^0
617-
// -3 t^2
618-
// 3 t^4
619-
// -1 t^6
620-
// 1 t^0
621-
// 3 t^1
622-
// 3 t^2
623-
// 1 t^3
624-
// dimension (affine) = 0
615+
...// dimension (affine) = 0
625616
// degree (affine) = 8
626617
627618
This is mainly useful if this method is called implicitly. Because
@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
631622
::
632623
633624
sage: o = s.hilb()
634-
// 1 t^0
635-
// -3 t^2
636-
// 3 t^4
637-
// -1 t^6
638-
// 1 t^0
639-
// 3 t^1
640-
// 3 t^2
641-
// 1 t^3
642-
// dimension (affine) = 0
625+
...// dimension (affine) = 0
643626
// degree (affine) = 8
644627
// ** right side is not a datum, assignment ignored
645628
...

src/sage/libs/singular/function.pyx

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
12411241
sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
12421242
sage: I = Ideal(I.groebner_basis())
12431243
sage: hilb = sage.libs.singular.function_factory.ff.hilb
1244-
sage: hilb(I) # Singular will print // ** _ is no standard basis
1245-
// ** _ is no standard basis
1246-
// 1 t^0
1247-
// -1 t^5
1248-
<BLANKLINE>
1249-
// 1 t^0
1250-
// 1 t^1
1251-
// 1 t^2
1252-
// 1 t^3
1253-
// 1 t^4
1254-
// dimension (proj.) = 1
1255-
// degree (proj.) = 5
1244+
sage: from sage.misc.sage_ostools import redirection
1245+
sage: out = tmp_filename()
1246+
sage: with redirection(sys.stdout, open(out, 'w')):
1247+
....: hilb(I) # Singular will print // ** _ is no standard basis
1248+
sage: with open(out) as f:
1249+
....: 'is no standard basis' in f.read()
1250+
True
12561251
12571252
So we tell Singular that ``I`` is indeed a Groebner basis::
12581253
1259-
sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
1260-
// 1 t^0
1261-
// -1 t^5
1262-
<BLANKLINE>
1263-
// 1 t^0
1264-
// 1 t^1
1265-
// 1 t^2
1266-
// 1 t^3
1267-
// 1 t^4
1268-
// dimension (proj.) = 1
1269-
// degree (proj.) = 5
1254+
sage: out = tmp_filename()
1255+
sage: with redirection(sys.stdout, open(out, 'w')):
1256+
....: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
1257+
sage: with open(out) as f:
1258+
....: 'is no standard basis' in f.read()
1259+
False
12701260
12711261
12721262
TESTS:

src/sage/rings/polynomial/multi_polynomial_ideal.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
31323132
sage: I.hilbert_numerator() # needs sage.rings.number_field
31333133
-t^5 + 1
31343134
3135-
This example returns a wrong answer due to an integer overflow in Singular::
3135+
This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
31363136
31373137
sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
31383138
sage: I = P.ideal(M.minors(2))
31393139
sage: J = P * [m.lm() for m in I.groebner_basis()]
3140-
sage: J.hilbert_numerator(algorithm='singular')
3141-
...120*t^33 - 3465*t^32 + 48180*t^31 - ...
3140+
sage: J.hilbert_numerator(algorithm='singular') # known bug
3141+
Traceback (most recent call last):
3142+
....
3143+
RuntimeError: error in Singular function call 'hilb':
3144+
overflow at t^22
31423145
31433146
Our two algorithms should always agree; not tested until
31443147
:trac:`33178` is fixed::

0 commit comments

Comments
 (0)