how to reduce libsingular verbosity?

60 views
Skip to first unread message

Brent W. Baccala

unread,
Jun 28, 2019, 1:33:56 PM6/28/19
to sage-devel
I'm trying to use some functions from Singular's "normal" library, which is pretty verbose, i.e:

sage: R.<x,y> = GF(3)[]
sage
: S = R.quo(ideal(y^4 + y - x^5))
sage
: from sage.libs.singular.function import singular_function
sage
: normalC = sage.libs.singular.function_factory.ff.normal__lib.normalC
sage
: normalC(S.defining_ideal(), ['withGens'])[1][0]


// 'normalC' created a list, say nor, of three lists:
// To see the list type
      nor
;


// * nor[1] is a list of 1 ring(s)
// To access the i-th ring nor[1][i] give it a name, say Ri, and type e.g.
     
def R1 = nor[1][1]; setring R1;  norid; normap;
// For the other rings type first (if R is the name of your original basering)
     setring R
;
// and then continue as for R1.
// Ri/norid is the affine algebra of the normalization of the i-th
// component R/P_i (where P_i is an associated prime of the input ideal id)
// and normap the normalization map from R to Ri/norid.


// * nor[2] is a list of 1 ideal(s), each ideal nor[2][i] consists of
// elements g1..gk of R such that the gj/gk generate the integral
// closure of R/P_i as sub-algebra in the quotient field of R/P_i, with
// gj/gk being mapped by normap to the j-th variable of Ri;


// * nor[3] shows the delta-invariant of each component and of id
// (-1 means infinite, and 0 that R/P_i resp. R/id is normal).
[y^4 + y, x^4*y, x^3*y^3 - x^3*y^2 + x^3*y, x^2*y^3 - x^2*y^2 + x^2*y, x^3*y^2 + x^3*y, x*y^3 - x*y^2 + x*y, x^4]
sage
:



I'd like to get rid of that long message and just see the result.

Is there any way to control Singular's "printlevel" variable from Sage?

Brent W. Baccala

unread,
Jul 1, 2019, 1:19:02 AM7/1/19
to sage-devel

This is what I figured out to adjust Singular's printlevel:

from sage.libs.singular import function_factory
execute
= function_factory.ff.execute
execute
('printlevel=-1')


Now that previous example runs without all the clutter:

sage: R.<x,y> = GF(3)[]
....: S = R.quo(ideal(y^4 + y - x^5))
....: from sage.libs.singular.function import singular_function
....: normalC = sage.libs.singular.function_factory.ff.normal__lib.normalC
....: normalC(S.defining_ideal(), ['withGens'])[1][0]
....:
Message has been deleted

Brent W. Baccala

unread,
Jul 1, 2019, 1:21:59 PM7/1/19
to sage-devel
Expanding on my previous answer, I found a way to save printlevel and restore it when I'm done.  The key idea is try to get a handle to a function that may not exist, then create it if it doesn't:

from sage.libs.singular.function import singular_function, lib
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')

saved_printlevel
= get_printlevel()
execute
('printlevel=-1')
pols_in_S
= normal(S.ideal(g))[1][0]
execute
('printlevel={}'.format(saved_printlevel))

Reply all
Reply to author
Forward
0 new messages