You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This ticket cleans up the `PolynomialRing()` function in many ways.
Mainly:
1. Use `normalize_names()` as much as possible to deal with variable
names.
2. Fix indentation in docstring.
3. Pass arguments like `sparse` and `implementation` as `**kwds` to the
single-variate or multi-variate polynomial constructor.
4. Make the code easier to understand.
5. Allow `PolynomialRing(..., implementation="singular")` which forces
Singular. This allows simplifying some code in
`src/sage/algebras/free_algebra.py` which currently needs to jump
through hoops to get a `MPolynomialRing_libsingular`.
6. Check more error conditions, for example currently we have
{{{
sage: PolynomialRing(QQ, name="x", names="y")
Univariate Polynomial Ring in y over Rational Field
}}}
7. Change some arguments of `PolynomialRing()` to keyword-only
arguments. This does break some existing uses of `PolynomialRing()`,
although much more likely in library code and not user code (some code
in Sage gets this even wrong and was passing `sparse="lex"` instead of
`order="lex"`)
Apart from items 6 and 7, no existing functionality is changed.
URL: https://trac.sagemath.org/23338
Reported by: jdemeyer
Ticket author(s): Jeroen Demeyer
Reviewer(s): Travis Scrimshaw
Copy file name to clipboardExpand all lines: src/sage/libs/singular/ring.pyx
+12-16
Original file line number
Diff line number
Diff line change
@@ -137,8 +137,8 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:
137
137
_ring =NULL
138
138
139
139
n =int(n)
140
-
if n<1:
141
-
raiseArithmeticError("The number of variables must be at least 1.")
140
+
if n<1:
141
+
raiseNotImplementedError(f"polynomials in {n} variables are not supported in Singular")
142
142
143
143
nvars = n
144
144
order = TermOrder(term_order, n)
@@ -226,10 +226,8 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:
226
226
227
227
elifisinstance(base_ring, NumberField) and base_ring.is_absolute():
228
228
characteristic =1
229
-
try:
230
-
k = PolynomialRing(RationalField(), 1, [base_ring.variable_name()], 'lex')
231
-
exceptTypeError:
232
-
raiseTypeError("The multivariate polynomial ring in a single variable %s in lex order over Rational Field is supposed to be of type %s"% (base_ring.variable_name(), MPolynomialRing_libsingular))
elif (isinstance(base_ring, FiniteField_generic) and base_ring.is_prime_field()):
260
-
#or (is_IntegerModRing(base_ring) and base_ring.characteristic().is_prime()):
261
-
262
258
if base_ring.characteristic() <=2147483647:
263
259
characteristic = base_ring.characteristic()
264
260
else:
@@ -274,11 +270,10 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:
274
270
characteristic =-base_ring.characteristic() # note the negative characteristic
275
271
else:
276
272
raiseTypeError("characteristic must be <= 2147483647.")
277
-
# TODO: This is lazy, it should only call Singular stuff not MPolynomial stuff
278
-
try:
279
-
k = PolynomialRing(base_ring.prime_subfield(), 1, [base_ring.variable_name()], 'lex')
280
-
exceptTypeError:
281
-
raiseTypeError("The multivariate polynomial ring in a single variable %s in lex order over %s is supposed to be of type %s"% (base_ring.variable_name(), base_ring,MPolynomialRing_libsingular))
273
+
274
+
# TODO: This is lazy, it should only call Singular stuff not PolynomialRing()
0 commit comments