Skip to content

Commit

Permalink
src/sage/algebras/letterplace: define singular functions locally
Browse files Browse the repository at this point in the history
These modules use singular_function() from sage.libs.singular.function
to create top-level aliases for a few singular functions. The docbuild
however tries to build documentation for these functions, and it can
raise an error if GNU info is not installed. There's no good reason to
define them globally in the first place (they are only used locally),
so an easy fix is to move the imports and variables local.
  • Loading branch information
orlitzky committed Nov 9, 2024
1 parent 2f030e9 commit d52b5e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ AUTHOR:
# ****************************************************************************

from sage.groups.perm_gps.permgroup_named import CyclicPermutationGroup
from sage.libs.singular.function import lib, singular_function
from sage.libs.singular.function import lib
from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal
from cpython.object cimport PyObject_RichCompare

# Define some singular functions
lib("freegb.lib")
poly_reduce = singular_function("NF")

#####################
# Free algebra elements
Expand Down Expand Up @@ -695,6 +694,8 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
bck = (libsingular_options['redTail'], libsingular_options['redSB'])
libsingular_options['redTail'] = True
libsingular_options['redSB'] = True
from sage.libs.singular.function import singular_function
poly_reduce = singular_function("NF")
poly = poly_reduce(C(self._poly), gI, ring=C,
attributes={gI: {"isSB": 1}})
libsingular_options['redTail'] = bck[0]
Expand Down
5 changes: 3 additions & 2 deletions src/sage/algebras/letterplace/free_algebra_letterplace.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ TESTS::
algebras with different term orderings, yet.
"""
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.libs.singular.function import lib, singular_function
from sage.libs.singular.function import lib
from sage.libs.singular.function cimport RingWrap
from sage.libs.singular.ring cimport singular_ring_delete, singular_ring_reference
from sage.categories.algebras import Algebras
Expand All @@ -132,7 +132,6 @@ from sage.misc.cachefunc import cached_method
#####################
# Define some singular functions
lib("freegb.lib")
freeAlgebra = singular_function("freeAlgebra")

# unfortunately we cannot set Singular attributes for MPolynomialRing_libsingular
# Hence, we must constantly work around Letterplace's sanity checks,
Expand Down Expand Up @@ -892,6 +891,8 @@ cdef class FreeAlgebra_letterplace_libsingular():

def __cinit__(self, MPolynomialRing_libsingular commutative_ring,
int degbound):
from sage.libs.singular.function import singular_function
freeAlgebra = singular_function("freeAlgebra")
cdef RingWrap rw = freeAlgebra(commutative_ring, degbound)
self._lp_ring = singular_ring_reference(rw._ring)
# `_lp_ring` viewed as `MPolynomialRing_libsingular` with additional
Expand Down
9 changes: 5 additions & 4 deletions src/sage/algebras/letterplace/letterplace_ideal.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,14 @@ AUTHOR:
# https://www.gnu.org/licenses/
# ****************************************************************************
from sage.rings.noncommutative_ideals import Ideal_nc
from sage.libs.singular.function import lib, singular_function
from sage.libs.singular.function import lib
from sage.algebras.letterplace.free_algebra_letterplace cimport FreeAlgebra_letterplace, FreeAlgebra_letterplace_libsingular
from sage.algebras.letterplace.free_algebra_element_letterplace cimport FreeAlgebraElement_letterplace
from sage.rings.infinity import Infinity

#####################
# Define some singular functions
lib("freegb.lib")
singular_twostd = singular_function("twostd")
poly_reduce = singular_function("NF")


class LetterplaceIdeal(Ideal_nc):
"""
Expand Down Expand Up @@ -321,6 +318,8 @@ class LetterplaceIdeal(Ideal_nc):
to_L = P.hom(L.gens(), L, check=False)
from_L = L.hom(P.gens(), P, check=False)
I = L.ideal([to_L(x._poly) for x in self.__GB.gens()])
from sage.libs.singular.function import singular_function
singular_twostd = singular_function("twostd")
gb = singular_twostd(I)
out = [FreeAlgebraElement_letterplace(A, from_L(X), check=False)
for X in gb]
Expand Down Expand Up @@ -398,6 +397,8 @@ class LetterplaceIdeal(Ideal_nc):
bck = (libsingular_options['redTail'], libsingular_options['redSB'])
libsingular_options['redTail'] = True
libsingular_options['redSB'] = True
from sage.libs.singular.function import singular_function
poly_reduce = singular_function("NF")
sI = poly_reduce(sI, gI, ring=C, attributes={gI: {"isSB": 1}})
libsingular_options['redTail'] = bck[0]
libsingular_options['redSB'] = bck[1]
Expand Down

0 comments on commit d52b5e5

Please sign in to comment.