Skip to content

Commit c7bb2cf

Browse files
committed
pr #36030: silence some Singular messages
1 parent 4f5e093 commit c7bb2cf

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/sage/rings/polynomial/multi_polynomial_libsingular.pyx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5757,24 +5757,23 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
57575757
else:
57585758
return self * self.denominator()
57595759

5760-
def in_subalgebra(self, J, algorithm=None):
5760+
def in_subalgebra(self, J, algorithm="algebra_containment"):
57615761
"""
57625762
Return whether this polynomial is contained in the subalgebra
57635763
generated by ``J``
57645764
57655765
INPUT:
57665766
5767-
- ``J`` -- iterable of elements of the parent polynomial ring
5767+
- ``J`` -- list of elements of the parent polynomial ring
57685768
57695769
- ``algorithm`` -- can be ``None`` (the default), "algebra_containment",
57705770
"inSubring", or "groebner".
57715771
5772-
- ``None`` (the default): use "algebra_containment".
5773-
5774-
- "algebra_containment": use Singular's ``algebra_containment`` function,
5772+
- "algebra_containment" (default): use Singular's
5773+
``algebra_containment`` function,
57755774
https://www.singular.uni-kl.de/Manual/4-2-1/sing_1247.htm#SEC1328. The
5776-
Singular documentation suggests that this is frequently faster than the
5777-
next option.
5775+
Singular documentation suggests that this is frequently
5776+
faster than the next option.
57785777
57795778
- "inSubring": use Singular's ``inSubring`` function,
57805779
https://www.singular.uni-kl.de/Manual/4-2-0/sing_1240.htm#SEC1321.
@@ -5789,31 +5788,37 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
57895788
and only if the remainder involves only the new variables
57905789
`z_i`.
57915790
5792-
Note: the default algorithm may print some intermediate information.
5793-
57945791
EXAMPLES::
57955792
57965793
sage: P.<x,y,z> = QQ[]
57975794
sage: J = [x^2 + y^2, x^2 + z^2]
57985795
sage: (y^2).in_subalgebra(J)
5799-
...
58005796
False
58015797
sage: a = (x^2 + y^2) * (x^2 + z^2)
58025798
sage: a.in_subalgebra(J, algorithm='inSubring')
58035799
True
58045800
sage: (a^2).in_subalgebra(J, algorithm='groebner')
58055801
True
58065802
sage: (a + a^2).in_subalgebra(J)
5807-
...
58085803
True
58095804
"""
58105805
R = self.parent()
5811-
if algorithm is not None:
5812-
algorithm = algorithm.lower()
5806+
algorithm = algorithm.lower()
58135807
from sage.libs.singular.function import singular_function, lib as singular_lib
58145808
singular_lib('algebra.lib')
5815-
if algorithm is None or algorithm == "algebra_containment":
5816-
return singular_function('algebra_containment')(self, R.ideal(J)) == 1
5809+
if algorithm == "algebra_containment":
5810+
execute = singular_function('execute')
5811+
try:
5812+
get_printlevel = singular_function('get_printlevel')
5813+
except NameError:
5814+
execute('proc get_printlevel {return (printlevel);}')
5815+
get_printlevel = singular_function('get_printlevel')
5816+
# It's fairly verbose unless printlevel is -1.
5817+
saved_printlevel = get_printlevel()
5818+
execute('printlevel=-1')
5819+
contains = singular_function('algebra_containment')(self, R.ideal(J)) == 1
5820+
execute('printlevel={}'.format(saved_printlevel))
5821+
return contains
58175822
elif algorithm == "insubring":
58185823
return singular_function('inSubring')(self, R.ideal(J))[0] == 1
58195824
elif algorithm == "groebner":

0 commit comments

Comments
 (0)