From d52b5e500cde2ad83d14db3b6bd8977fdb8c766c Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 8 Nov 2024 19:40:06 -0500 Subject: [PATCH] src/sage/algebras/letterplace: define singular functions locally 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. --- .../letterplace/free_algebra_element_letterplace.pyx | 5 +++-- .../algebras/letterplace/free_algebra_letterplace.pyx | 5 +++-- src/sage/algebras/letterplace/letterplace_ideal.pyx | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx index 2a977b1a513..aa164d6a4ce 100644 --- a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx +++ b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx @@ -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 @@ -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] diff --git a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx index 7a57922d24a..10146c36aeb 100644 --- a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx +++ b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx @@ -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 @@ -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, @@ -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 diff --git a/src/sage/algebras/letterplace/letterplace_ideal.pyx b/src/sage/algebras/letterplace/letterplace_ideal.pyx index 77d0107ba07..33e8a80c039 100644 --- a/src/sage/algebras/letterplace/letterplace_ideal.pyx +++ b/src/sage/algebras/letterplace/letterplace_ideal.pyx @@ -41,7 +41,7 @@ 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 @@ -49,9 +49,6 @@ 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): """ @@ -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] @@ -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]