Skip to content

Commit ad3aa56

Browse files
committed
Support singular older than 4.3.2.p15 too
1 parent 79bbec1 commit ad3aa56

File tree

6 files changed

+47
-17
lines changed

6 files changed

+47
-17
lines changed

src/sage/interfaces/singular.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,15 +1206,18 @@ def current_ring(self):
12061206
12071207
EXAMPLES::
12081208
1209+
sage: import re
12091210
sage: r = PolynomialRing(GF(127),3,'xyz', order='invlex')
1210-
sage: r._singular_()
1211+
sage: rsing = r._singular_()
1212+
sage: print(re.sub('ordering rp', 'ordering ip', rsing._repr_()))
12111213
polynomial ring, over a field, global ordering
12121214
// coefficients: ZZ/127
12131215
// number of vars : 3
12141216
// block 1 : ordering ip
12151217
// : names x y z
12161218
// block 2 : ordering C
1217-
sage: singular.current_ring()
1219+
sage: curring = singular.current_ring()
1220+
sage: print(re.sub('ordering rp', 'ordering ip', curring._repr_()))
12181221
polynomial ring, over a field, global ordering
12191222
// coefficients: ZZ/127
12201223
// number of vars : 3
@@ -2469,6 +2472,20 @@ def singular_version():
24692472
return singular.eval('system("--version");')
24702473

24712474

2475+
def singular_version_number():
2476+
"""
2477+
Return the version number of Singular being used as a string.
2478+
2479+
EXAMPLES::
2480+
2481+
sage: singular.version_number()
2482+
'4...'
2483+
"""
2484+
import re
2485+
r = re.compile(r"\((\d+),")
2486+
return r.findall(singular_version())[0]
2487+
2488+
24722489
class SingularGBLogPrettyPrinter:
24732490
"""
24742491
A device which prints Singular Groebner basis computation logs

src/sage/libs/singular/decl.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ cdef extern from "singular/Singular/libsingular.h":
243243
ringorder_s
244244
ringorder_lp
245245
ringorder_dp
246+
ringorder_rp
246247
ringorder_ip
247248
ringorder_Dp
248249
ringorder_wp

src/sage/libs/singular/function.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ cdef class SingularFunction(SageObject):
12331233
Traceback (most recent call last):
12341234
...
12351235
RuntimeError: error in Singular function call 'size':
1236-
Wrong number of arguments (got 2 arguments, arity code is 303)
1236+
Wrong number of arguments (got 2 arguments, arity code is 30...)
12371237
sage: size('foobar', ring=P)
12381238
6
12391239
@@ -1636,17 +1636,17 @@ def singular_function(name):
16361636
Traceback (most recent call last):
16371637
...
16381638
RuntimeError: error in Singular function call 'factorize':
1639-
Wrong number of arguments (got 0 arguments, arity code is 306)
1639+
Wrong number of arguments (got 0 arguments, arity code is 30...)
16401640
sage: factorize(f, 1, 2)
16411641
Traceback (most recent call last):
16421642
...
16431643
RuntimeError: error in Singular function call 'factorize':
1644-
Wrong number of arguments (got 3 arguments, arity code is 306)
1644+
Wrong number of arguments (got 3 arguments, arity code is 30...)
16451645
sage: factorize(f, 1, 2, 3)
16461646
Traceback (most recent call last):
16471647
...
16481648
RuntimeError: error in Singular function call 'factorize':
1649-
Wrong number of arguments (got 4 arguments, arity code is 306)
1649+
Wrong number of arguments (got 4 arguments, arity code is 30...)
16501650
16511651
The Singular function ``list`` can be called with any number of
16521652
arguments::

src/sage/libs/singular/ring.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ from sage.libs.gmp.mpz cimport mpz_init_set_ui
2424
from sage.libs.singular.decl cimport ring, currRing
2525
from sage.libs.singular.decl cimport rChangeCurrRing, rComplete, rDelete, idInit
2626
from sage.libs.singular.decl cimport omAlloc0, omStrDup, omAlloc
27-
from sage.libs.singular.decl cimport ringorder_dp, ringorder_Dp, ringorder_lp, ringorder_ip, ringorder_ds, ringorder_Ds, ringorder_ls, ringorder_M, ringorder_c, ringorder_C, ringorder_wp, ringorder_Wp, ringorder_ws, ringorder_Ws, ringorder_a, rRingOrder_t
27+
from sage.libs.singular.decl cimport ringorder_dp, ringorder_Dp, ringorder_lp, ringorder_ip, ringorder_rp, ringorder_ds, ringorder_Ds, ringorder_ls, ringorder_M, ringorder_c, ringorder_C, ringorder_wp, ringorder_Wp, ringorder_ws, ringorder_Ws, ringorder_a, rRingOrder_t
2828
from sage.libs.singular.decl cimport prCopyR
2929
from sage.libs.singular.decl cimport n_unknown, n_algExt, n_transExt, n_Z, n_Zn, n_Znm, n_Z2m
3030
from sage.libs.singular.decl cimport n_coeffType
@@ -50,17 +50,12 @@ from cpython.object cimport Py_EQ, Py_NE
5050

5151
from collections import defaultdict
5252

53-
54-
55-
56-
57-
5853
# mapping str --> SINGULAR representation
54+
5955
order_dict = {
6056
"dp": ringorder_dp,
6157
"Dp": ringorder_Dp,
6258
"lp": ringorder_lp,
63-
"ip": ringorder_ip,
6459
"ds": ringorder_ds,
6560
"Ds": ringorder_Ds,
6661
"ls": ringorder_ls,
@@ -71,6 +66,11 @@ order_dict = {
7166
"a": ringorder_a,
7267
}
7368

69+
from sage.interfaces.singular import singular_version_number
70+
if int(singular_version_number()[0:3]) < 432 or (int(singular_version_number()[0:3]) == 432 and int(singular_version_number()[3:]) < 15):
71+
order_dict["rp"] = ringorder_rp
72+
else:
73+
order_dict["ip"] = ringorder_ip
7474

7575
#############################################################################
7676
cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:

src/sage/rings/polynomial/multi_polynomial_libsingular.pyx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,26 +1280,32 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base):
12801280
// : names x y
12811281
// block 2 : ordering C
12821282
1283+
sage: import re
12831284
sage: R = PolynomialRing(GF(2**8,'a'),10,'x', order='invlex') # needs sage.rings.finite_rings
1284-
sage: singular(R) # needs sage.rings.finite_rings
1285+
sage: out = singular(R) # needs sage.rings.finite_rings
1286+
sage: print(re.sub('ordering rp', 'ordering ip', out._repr_())) # needs sage.rings.finite_rings
12851287
polynomial ring, over a field, global ordering
12861288
// coefficients: ZZ/2[a]/(a^8+a^4+a^3+a^2+1)
12871289
// number of vars : 10
12881290
// block 1 : ordering ip
12891291
// : names x0 x1 x2 x3 x4 x5 x6 x7 x8 x9
12901292
// block 2 : ordering C
12911293
1294+
sage: import re
12921295
sage: R = PolynomialRing(GF(127),2,'x', order='invlex')
1293-
sage: singular(R) # needs sage.rings.finite_rings
1296+
sage: out = singular(R) # needs sage.rings.finite_rings
1297+
sage: print(re.sub('ordering rp', 'ordering ip', out._repr_())) # needs sage.rings.finite_rings
12941298
polynomial ring, over a field, global ordering
12951299
// coefficients: ZZ/127
12961300
// number of vars : 2
12971301
// block 1 : ordering ip
12981302
// : names x0 x1
12991303
// block 2 : ordering C
13001304
1305+
sage: import re
13011306
sage: R = PolynomialRing(QQ,2,'x', order='invlex')
1302-
sage: singular(R) # needs sage.rings.function_field
1307+
sage: out = singular(R) # needs sage.rings.function_field
1308+
sage: print(re.sub('ordering rp', 'ordering ip', out._repr_())) # needs sage.rings.function_field
13031309
polynomial ring, over a field, global ordering
13041310
// coefficients: QQ
13051311
// number of vars : 2

src/sage/rings/polynomial/term_order.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,15 @@
386386
'negwdeglex' : 'Negative weighted degree lexicographic',
387387
}
388388

389+
from sage.interfaces.singular import singular_version_number
390+
if int(singular_version_number()[0:3]) < 432 or (int(singular_version_number()[0:3]) == 432 and int(singular_version_number()[3:]) < 15):
391+
invlex_singular_name = 'rp'
392+
else:
393+
invlex_singular_name = 'ip'
394+
389395
singular_name_mapping = {
390396
'lex' : 'lp',
391-
'invlex' : 'ip',
397+
'invlex' : invlex_singular_name,
392398
'degrevlex' : 'dp',
393399
'deglex' : 'Dp',
394400
'neglex' : 'ls',

0 commit comments

Comments
 (0)