Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Set binding=False for internal methods in cdef class
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Nov 21, 2022
1 parent 735fbcf commit 104cb22
Show file tree
Hide file tree
Showing 229 changed files with 1,693 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sage/algebras/clifford_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ AUTHORS:
# http://www.gnu.org/licenses/
#*****************************************************************************

cimport cython
from sage.structure.parent cimport Parent
from sage.data_structures.bitset cimport Bitset
from sage.algebras.weyl_algebra import repr_from_monomials
Expand All @@ -35,6 +36,7 @@ cdef class CliffordAlgebraElement(IndexedFreeModuleElement):
sage: elt = ((x^3-z)*x + y)^2
sage: TestSuite(elt).run()
"""
@cython.binding(False)
def _repr_(self):
"""
Return a string representation of ``self``.
Expand All @@ -50,6 +52,7 @@ cdef class CliffordAlgebraElement(IndexedFreeModuleElement):
"""
return repr_from_monomials(self.list(), self._parent._repr_term)

@cython.binding(False)
def _latex_(self):
r"""
Return a `\LaTeX` representation of ``self``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Elements of Finite Algebras
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************
cimport cython
import re

from sage.misc.lazy_attribute import lazy_attribute
Expand Down Expand Up @@ -180,6 +181,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
except AttributeError:
pass

@cython.binding(False)
@property
def _matrix(self):
"""
Expand Down Expand Up @@ -269,6 +271,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
return sum([self._vector[0,i] * A.left_table()[i] for
i in range(A.degree())])

@cython.binding(False)
def _repr_(self):
"""
Return the string representation of ``self``.
Expand Down Expand Up @@ -305,6 +308,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
return "0"
return s[1:]

@cython.binding(False)
def _latex_(self):
r"""
Return the LaTeX representation of ``self``.
Expand Down Expand Up @@ -499,6 +503,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
"""
return self._inverse is not None

@cython.binding(False)
@property
def _inverse(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ AUTHOR:
# https://www.gnu.org/licenses/
# ****************************************************************************

cimport cython
from sage.groups.perm_gps.all import CyclicPermutationGroup
from sage.libs.singular.function import lib, singular_function
from sage.misc.repr import repr_lincomb
Expand Down Expand Up @@ -145,6 +146,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
cdef dict d = self._poly.dict()
yield from d.iteritems()

@cython.binding(False)
def _repr_(self):
"""
TESTS::
Expand Down Expand Up @@ -227,6 +229,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
return ' '.join(L)
return '0'

@cython.binding(False)
def _latex_(self):
r"""
TESTS::
Expand Down
8 changes: 8 additions & 0 deletions src/sage/algebras/letterplace/free_algebra_letterplace.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ TESTS::
"""

cimport cython
from sage.misc.misc_c import prod
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.libs.singular.function import lib, singular_function
Expand Down Expand Up @@ -435,6 +436,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
"""
return (not (self.__ngens - self._nb_slackvars)) and self._base.is_field(proof=proof)

@cython.binding(False)
def _repr_(self):
"""
EXAMPLES::
Expand All @@ -451,6 +453,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
"""
return "Free Associative Unital Algebra on %d generators %s over %s" % (self.__ngens - self._nb_slackvars, self.gens(), self._base)

@cython.binding(False)
def _latex_(self):
r"""
Representation of this free algebra in LaTeX.
Expand Down Expand Up @@ -533,6 +536,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
################################################
# Ideals

@cython.binding(False)
def _ideal_class_(self, n=0):
"""
Return the class :class:`~sage.algebras.letterplace.letterplace_ideal.LetterplaceIdeal`.
Expand Down Expand Up @@ -640,6 +644,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
i += (self._degrees[var_ind] - 1)
return ' '.join(out)

@cython.binding(False)
def _reductor_(self, g, d):
"""
Return a commutative ideal that can be used to compute the normal
Expand Down Expand Up @@ -743,6 +748,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
return False
return True

@cython.binding(False)
def _an_element_(self):
"""
Return an element.
Expand Down Expand Up @@ -777,6 +783,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
# break
# return FreeAlgebraElement_letterplace(self, p, check=False)

@cython.binding(False)
def _from_dict_(self, dict D, check=True):
"""
Create an element from a dictionary.
Expand Down Expand Up @@ -822,6 +829,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
return FreeAlgebraElement_letterplace(self, self._current_ring(out),
check=check)

@cython.binding(False)
def _element_constructor_(self, x):
"""
Return an element of this free algebra.
Expand Down
16 changes: 16 additions & 0 deletions src/sage/algebras/lie_algebras/lie_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ AUTHORS:
# https://www.gnu.org/licenses/
# ****************************************************************************

cimport cython
from copy import copy
from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE

Expand Down Expand Up @@ -82,6 +83,7 @@ cdef class LieAlgebraElement(IndexedFreeModuleElement):
right = (<LieAlgebraElement> right).lift()
return left * right

@cython.binding(False)
def _im_gens_(self, codomain, im_gens, base_map=None):
"""
Return the image of ``self`` in ``codomain`` under the
Expand Down Expand Up @@ -522,6 +524,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
except KeyError:
return self.parent().base_ring().zero()

@cython.binding(False)
def _bracket_(self, x):
"""
Return the Lie bracket ``[self, x]``.
Expand Down Expand Up @@ -697,6 +700,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
"""
An element of a Lie algebra given by structure coefficients.
"""
@cython.binding(False)
def _repr_(self):
"""
EXAMPLES::
Expand All @@ -710,6 +714,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
repr_monomial=self._parent._repr_generator,
strip_one=True)

@cython.binding(False)
def _latex_(self):
r"""
EXAMPLES::
Expand All @@ -725,6 +730,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
repr_monomial=self._parent._latex_term,
is_latex=True, strip_one=True)

@cython.binding(False)
def _ascii_art_(self):
r"""
Return an ascii art representation of ``self``.
Expand All @@ -741,6 +747,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
repr_monomial=ascii_art,
strip_one=True))

@cython.binding(False)
def _unicode_art_(self):
r"""
Return a unicode art representation of ``self``.
Expand Down Expand Up @@ -929,6 +936,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
return (_build_untwisted_affine_element,
(self._parent, self._t_dict, self._c_coeff, self._d_coeff))

@cython.binding(False)
def _repr_generic(self, style, coeff, t_disp, mult, tensor_symb):
"""
Return a representation of ``self`` based on ``style``.
Expand Down Expand Up @@ -975,6 +983,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
return style('0')
return ret

@cython.binding(False)
def _repr_(self):
"""
Return a string representation of ``self``.
Expand Down Expand Up @@ -1004,6 +1013,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
"""
return self._repr_generic(str, str, lambda t: "t^{}".format(t), '*', '#')

@cython.binding(False)
def _latex_(self):
r"""
Return a latex representation of ``self``.
Expand Down Expand Up @@ -1035,6 +1045,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
from sage.misc.latex import latex
return self._repr_generic(str, latex, lambda t: "t^{{{}}}".format(t), ' ', ' \\otimes ')

@cython.binding(False)
def _unicode_art_(self):
r"""
Return a unicode art representation of ``self``.
Expand Down Expand Up @@ -1546,6 +1557,7 @@ cdef class LieGenerator(LieObject):
"""
return (LieGenerator, (self._name, self._index_word[0]))

@cython.binding(False)
def _repr_(self):
"""
Return a string representation of ``self``.
Expand Down Expand Up @@ -1611,6 +1623,7 @@ cdef class LieGenerator(LieObject):
return richcmp(self._index_word[0], <LieGenerator>(rhs)._index_word[0], op)
return op == Py_NE

@cython.binding(False)
def _im_gens_(self, codomain, im_gens, names):
"""
Return the image of ``self`` in ``codomain`` under the
Expand Down Expand Up @@ -1682,6 +1695,7 @@ cdef class LieBracket(LieObject):
"""
return (LieBracket, (self._left, self._right))

@cython.binding(False)
def _repr_(self):
"""
Return a string representation of ``self``.
Expand All @@ -1696,6 +1710,7 @@ cdef class LieBracket(LieObject):
"""
return "[{!s}, {!s}]".format(self._left, self._right)

@cython.binding(False)
def _latex_(self):
r"""
Return a `\LaTeX` representation of ``self``.
Expand Down Expand Up @@ -1795,6 +1810,7 @@ cdef class LieBracket(LieObject):
self._hash = hash((self._left, self._right))
return self._hash

@cython.binding(False)
def _im_gens_(self, codomain, im_gens, names):
"""
Return the image of ``self`` in ``codomain`` under the
Expand Down
8 changes: 8 additions & 0 deletions src/sage/algebras/quatalg/quaternion_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Check that :trac:`20829` is fixed::
# https://www.gnu.org/licenses/
# ****************************************************************************

cimport cython
from sage.structure.element cimport AlgebraElement, RingElement, ModuleElement, Element
from sage.structure.richcmp cimport rich_to_bool, rich_to_bool_sgn, richcmp_item
from sage.algebras.quatalg.quaternion_algebra_element cimport QuaternionAlgebraElement_abstract
Expand Down Expand Up @@ -281,6 +282,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
return float(self[0])
raise TypeError

@cython.binding(False)
def _integer_(self, ZZ=None):
"""
Try to coerce this quaternion to an Integer.
Expand All @@ -305,6 +307,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
return Integer(self[0])
raise TypeError

@cython.binding(False)
def _rational_(self):
"""
Try to coerce this quaternion to a Rational.
Expand Down Expand Up @@ -365,6 +368,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
return '0'
return ' + '.join(v).replace('+ -','- ')

@cython.binding(False)
def _repr_(self):
"""
Return string representation of this quaternion.
Expand Down Expand Up @@ -840,6 +844,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):

return QuaternionAlgebraElement_generic(self._parent, (x, y, z, w), check=False)

@cython.binding(False)
def _repr_(self):
"""
Print representation of ``self``.
Expand Down Expand Up @@ -905,6 +910,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
mpz_clear(self.b)
mpz_clear(self.d)

@cython.binding(False)
def _rational_(self):
"""
Try to coerce this quaternion to a Rational.
Expand Down Expand Up @@ -1585,6 +1591,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
mpq_canonicalize(w.value)
return (x, y, z, w)

@cython.binding(False)
def _multiply_by_integer(self, Integer n):
"""
Return the product of self times the integer n.
Expand Down Expand Up @@ -1622,6 +1629,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst

return result

@cython.binding(False)
def _divide_by_integer(self, Integer n):
"""
Return the quotient of self by the integer n.
Expand Down
4 changes: 4 additions & 0 deletions src/sage/arith/multi_modular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Utility classes for multi-modular algorithms
# https://www.gnu.org/licenses/
# ****************************************************************************

cimport cython
from cysignals.memory cimport check_allocarray, check_reallocarray, sig_free

from sage.libs.gmp.mpz cimport *
Expand Down Expand Up @@ -301,6 +302,7 @@ cdef class MultiModularBasis_base():
"""
return (self.list(), self._l_bound, self._u_bound)

@cython.binding(False)
def _extend_moduli_to_height(self, height):
"""
EXAMPLES::
Expand Down Expand Up @@ -394,6 +396,7 @@ cdef class MultiModularBasis_base():
return self.extend_with_primes(new_moduli, new_partial_products,
check=False)

@cython.binding(False)
def _extend_moduli_to_count(self, int count):
r"""
Expand the list of primes and perform precomputations.
Expand Down Expand Up @@ -428,6 +431,7 @@ cdef class MultiModularBasis_base():

return self.extend_with_primes(new_moduli, check=False)

@cython.binding(False)
def _extend_moduli(self, count):
"""
Expand the list of prime moduli with `count` new random primes.
Expand Down
2 changes: 2 additions & 0 deletions src/sage/calculus/riemann.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Development supported by NSF award No. 0702939.
# https://www.gnu.org/licenses/
# ****************************************************************************

cimport cython
from cysignals.signals cimport sig_on, sig_off

from sage.misc.decorators import options
Expand Down Expand Up @@ -280,6 +281,7 @@ cdef class Riemann_Map:
self._generate_interior_mapper()
self._generate_inverse_mapper()

@cython.binding(False)
def _repr_(self):
"""
Return a string representation of this :class:`Riemann_Map` object.
Expand Down
Loading

0 comments on commit 104cb22

Please sign in to comment.