diff --git a/src/sage/libs/singular/decl.pxd b/src/sage/libs/singular/decl.pxd index 320044a9372..0c9f2cc993c 100644 --- a/src/sage/libs/singular/decl.pxd +++ b/src/sage/libs/singular/decl.pxd @@ -425,6 +425,7 @@ cdef extern from "singular/Singular/libsingular.h": cdef int si_opt_2 # previously 'verbose' cdef void * currentVoice cdef int myynest + cdef int printlevel ctypedef char * const_char_ptr "const char *" cdef extern void (*WerrorS_callback)(const_char_ptr) diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx index b1ca9b511de..c6f65eb718a 100644 --- a/src/sage/libs/singular/function.pyx +++ b/src/sage/libs/singular/function.pyx @@ -1823,6 +1823,45 @@ def lib(name): raise NameError("Singular library {!r} not found".format(name)) +def get_printlevel(): + """ + Return the value of the variable ``printlevel``. + + This is useful to switch off and back the comments. + + EXAMPLES:: + + sage: from sage.libs.singular.function import get_printlevel, set_printlevel + sage: l = get_printlevel() + sage: set_printlevel(-1) + sage: get_printlevel() + -1 + sage: set_printlevel(l) + """ + global printlevel + cdef int pl = printlevel + return pl + + +def set_printlevel(l): + """ + Set the value of the variable ``printlevel``. + + This is useful to switch off and back the comments. + + EXAMPLES:: + + sage: from sage.libs.singular.function import get_printlevel, set_printlevel + sage: l = get_printlevel() + sage: set_printlevel(2) + sage: get_printlevel() + 2 + sage: set_printlevel(l) + """ + global printlevel + printlevel = l + + def list_of_functions(packages=False): """ Return a list of all function names currently available. diff --git a/src/sage/rings/function_field/function_field_polymod.py b/src/sage/rings/function_field/function_field_polymod.py index 9a34fe97e3e..de6cbf47a6c 100644 --- a/src/sage/rings/function_field/function_field_polymod.py +++ b/src/sage/rings/function_field/function_field_polymod.py @@ -2380,22 +2380,17 @@ def _singular_normal(ideal): sage: _singular_normal(ideal(f)) [[1]] """ - from sage.libs.singular.function import singular_function, lib - lib('normal.lib') + from sage.libs.singular.function import (singular_function, + lib as singular_lib, + get_printlevel, set_printlevel) + singular_lib('normal.lib') normal = singular_function('normal') - execute = singular_function('execute') - try: - get_printlevel = singular_function('get_printlevel') - except NameError: - execute('proc get_printlevel {return (printlevel);}') - get_printlevel = singular_function('get_printlevel') - - # It's fairly verbose unless printlevel is -1. + # verbose unless printlevel is -1. saved_printlevel = get_printlevel() - execute('printlevel=-1') + set_printlevel(-1) nor = normal(ideal) - execute('printlevel={}'.format(saved_printlevel)) + set_printlevel(saved_printlevel) return nor[1] diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx index d108d269082..318a58e6d9c 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx @@ -5837,20 +5837,17 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): """ R = self.parent() algorithm = algorithm.lower() - from sage.libs.singular.function import singular_function, lib as singular_lib + from sage.libs.singular.function import (singular_function, + get_printlevel, + set_printlevel, + lib as singular_lib) singular_lib('algebra.lib') if algorithm == "algebra_containment": - execute = singular_function('execute') - try: - get_printlevel = singular_function('get_printlevel') - except NameError: - execute('proc get_printlevel {return (printlevel);}') - get_printlevel = singular_function('get_printlevel') - # It's fairly verbose unless printlevel is -1. + # verbose unless printlevel is -1. saved_printlevel = get_printlevel() - execute('printlevel=-1') + set_printlevel(-1) contains = singular_function('algebra_containment')(self, R.ideal(J)) == 1 - execute('printlevel={}'.format(saved_printlevel)) + set_printlevel(saved_printlevel) return contains elif algorithm == "insubring": return singular_function('inSubring')(self, R.ideal(J))[0] == 1 diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py index 2757f11ca81..a695f45411b 100755 --- a/src/sage/schemes/curves/projective_curve.py +++ b/src/sage/schemes/curves/projective_curve.py @@ -141,6 +141,7 @@ from sage.categories.fields import Fields from sage.categories.homset import hom, Hom, End from sage.categories.number_fields import NumberFields +from sage.libs.singular.function import singular_function, lib as singular_lib, get_printlevel, set_printlevel from sage.matrix.constructor import matrix from sage.misc.cachefunc import cached_method from sage.misc.lazy_attribute import lazy_attribute @@ -1662,10 +1663,18 @@ def is_complete_intersection(self): sage: C.is_complete_intersection() False """ - singular.lib("sing.lib") - id = singular.simplify(self.defining_ideal(), 10) - L = singular.is_ci(id).sage() - return len(self.ambient_space().gens()) - len(id.sage().gens()) == L[-1] + singular_lib("sing.lib") + simplify = singular_function("simplify") + is_ci = singular_function("is_ci") + + # verbose unless printlevel is -1. + saved_printlevel = get_printlevel() + set_printlevel(-1) + id = simplify(self.defining_ideal(), 10) + L = is_ci(id)[-1] + set_printlevel(saved_printlevel) + + return len(self.ambient_space().gens()) - len(id) == L def tangent_line(self, p): """ @@ -1860,11 +1869,13 @@ def rational_parameterization(self): raise TypeError("this curve must have geometric genus zero") if not isinstance(self.base_ring(), RationalField): raise TypeError("this curve must be defined over the rational field") + singular.lib("paraplanecurves.lib") - R = singular.paraPlaneCurve(self.defining_polynomial()) - singular.setring(R) - param = singular('PARA').sage().gens() + R = singular.paraPlaneCurve(self.defining_polynomial()) # ring + R.set_ring() + param = singular('PARA').sage().gens() # ideal R = R.sage() + C = self.change_ring(R.base_ring()) H = Hom(ProjectiveSpace(R.base_ring(), 1, R.gens()), C) return H(param) @@ -2043,7 +2054,7 @@ def _points_via_singular(self, sort=True): X2 = singular.NSplaces(1, X1) R = X2[5][1][1] - singular.set_ring(R) + R.set_ring() # We use sage_flattened_str_list since iterating through # the entire list through the sage/singular interface directly @@ -2127,7 +2138,7 @@ def riemann_roch_basis(self, D): pnts = [(int(v[i][0]), int(v[i][2])-1) for i in range(len(v))] # retrieve coordinates of rational points R = X2[5][1][1] - singular.set_ring(R) + R.set_ring() v = singular('POINTS').sage_flattened_str_list() coords = [self(int(v[3*i]), int(v[3*i+1]), int(v[3*i+2])) for i in range(len(v)//3)] # build correct representation of D for singular