Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for updating Cython to 3.0.0 #36109

Merged
merged 54 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
0eda50b
rename __cached_methods -> _cached_methods
infmagic2047 Aug 7, 2023
f757334
rename __init_fun -> _init_fun
infmagic2047 Aug 7, 2023
65345ca
rename __value -> _value
infmagic2047 Aug 7, 2023
6ec8415
rename __hardy_z_function -> _hardy_z_function
infmagic2047 Aug 7, 2023
07062aa
rename __compute_rank -> _compute_rank
infmagic2047 Aug 7, 2023
7c7eab4
rename __typedN -> _typedN
infmagic2047 Aug 7, 2023
1f0654f
rename __find_zeros_v -> _find_zeros_v
infmagic2047 Aug 7, 2023
88823c6
rename __find_zeros -> _find_zeros
infmagic2047 Aug 7, 2023
bfe4218
rename __is_exchange_pair -> _is_exchange_pair
infmagic2047 Aug 7, 2023
c8fded5
rename __exchange -> _exchange
infmagic2047 Aug 7, 2023
49a6a8f
rename __exchange_value -> _exchange_value_internal
infmagic2047 Aug 7, 2023
8f9f7c0
rename __coclosure -> _coclosure_internal
infmagic2047 Aug 7, 2023
a91aac3
rename __pack -> _pack
infmagic2047 Aug 17, 2023
573d085
rename __move -> _move
infmagic2047 Aug 17, 2023
7c56ec5
rename __modulus -> _modulus
infmagic2047 Aug 7, 2023
03e6b0b
rename __normalize -> _normalize
infmagic2047 Aug 7, 2023
bb94714
rename __coeffs -> _coeffs
infmagic2047 Aug 7, 2023
a59885c
rename __ngens -> _ngens
infmagic2047 Aug 7, 2023
5caf2ca
rename __ideal_monoid -> _ideal_monoid
infmagic2047 Aug 17, 2023
230ebf8
rename __allocated -> _allocated
infmagic2047 Aug 7, 2023
6c39b64
rename __denominator -> _denominator
infmagic2047 Aug 7, 2023
10b7918
rename __numerator -> _numerator
infmagic2047 Aug 7, 2023
3517dde
rename __temporarily_change_names -> _temporarily_change_names
infmagic2047 Aug 7, 2023
826c430
rename __term_order -> _term_order
infmagic2047 Aug 7, 2023
251d36b
rename __custom_name -> _custom_name
infmagic2047 Aug 7, 2023
252f0bb
rename __crt -> _crt
infmagic2047 Aug 7, 2023
75f522d
rename __is_gen -> _is_gen
infmagic2047 Aug 17, 2023
2ee4332
rename __subset -> _subset_internal
infmagic2047 Aug 17, 2023
8386b4e
rename __relabel -> _relabel
infmagic2047 Aug 17, 2023
d799994
rename __fld_denominator -> _fld_denominator
infmagic2047 Aug 7, 2023
dedfbf7
rename __fld_numerator -> _fld_numerator
infmagic2047 Aug 7, 2023
117880c
rename __prec -> _prec
infmagic2047 Aug 7, 2023
fddd81b
rename __poly -> _poly
infmagic2047 Aug 7, 2023
66def0d
fix private methods used in doctests
infmagic2047 Aug 7, 2023
297a1ec
fix string representations of ClusterComplex and SubwordComplex
infmagic2047 Aug 17, 2023
01075fc
fix docs about renamed attributes
infmagic2047 Aug 17, 2023
5e7e1ba
avoid naming cython attributes __module__
infmagic2047 Aug 7, 2023
eaae799
force __getmetaclass__ to be a METH_NOARGS method
infmagic2047 Aug 7, 2023
9660827
fix structmember.h defines in cython 3
infmagic2047 Aug 7, 2023
6820d2a
avoid StopIteration in generators
infmagic2047 Aug 7, 2023
33eb23e
remove coxeter CoxGraph which fails to compile with cython 3
infmagic2047 Aug 8, 2023
bfd17cc
handle StopIteration in lazy_list_from_function
infmagic2047 Aug 19, 2023
878c1f7
adapt for Cython 3 module names in inspection
infmagic2047 Aug 19, 2023
1f90bce
remove __rtruediv__ definitions which fail to compile with Cython 3
infmagic2047 Aug 19, 2023
f8e84be
ensure correct caching for no-args methods not having METH_NOARGS
infmagic2047 Aug 19, 2023
23791f1
update docs about __getmetaclass__
infmagic2047 Aug 19, 2023
0c4d1de
fix detection of functions for session saving
infmagic2047 Aug 19, 2023
0e2164e
fix pickling of class methods
infmagic2047 Aug 20, 2023
4641801
fix cython metaclass Sage_PyType_Ready
infmagic2047 Aug 20, 2023
1c4a223
remove python 2 compat code in pickleMethod and unpickleMethod
infmagic2047 Aug 23, 2023
08ddad9
rephrase comments in cython_metaclass.h
infmagic2047 Aug 25, 2023
d819017
small changes to custom names
infmagic2047 Aug 25, 2023
fd38365
make custom name attribute private to SageObject
infmagic2047 Aug 25, 2023
4b85613
fix test failures
infmagic2047 Aug 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/en/thematic_tutorials/coercion_and_categories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ This base class provides a lot more methods than a general parent::

sage: [p for p in dir(Field) if p not in dir(Parent)]
['__fraction_field',
'__ideal_monoid',
'__iter__',
'__len__',
'__rxor__',
Expand All @@ -119,6 +118,7 @@ This base class provides a lot more methods than a general parent::
'_default_category',
'_gens',
'_ideal_class_',
'_ideal_monoid',
'_latex_names',
'_list',
'_one_element',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ http://docs.python.org/library/ for a complete list. ::
sage: el
bla
sage: el.__dict__
{'__custom_name': 'bla', 'value': 42}
{'_SageObject__custom_name': 'bla', 'value': 42}

Lots of Sage objects are not Python objects but compiled Cython
objects. Python sees them as builtin objects and you do not have
Expand Down
5 changes: 2 additions & 3 deletions src/sage/algebras/letterplace/free_algebra_letterplace.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ cdef class FreeAlgebra_letterplace_libsingular():
cdef ring* _lp_ring
cdef MPolynomialRing_libsingular _commutative_ring
cdef MPolynomialRing_libsingular _lp_ring_internal
cdef object __ngens
cdef object _ngens

cdef class FreeAlgebra_letterplace(Algebra):
cdef MPolynomialRing_libsingular _commutative_ring
cdef MPolynomialRing_libsingular _current_ring
cdef int _degbound
cdef int __ngens
cdef int _ngens
cdef int _nb_slackvars
cdef object __monoid
cdef public object __custom_name
cdef str exponents_to_string(self, E)
cdef str exponents_to_latex(self, E)
cdef tuple _degrees
34 changes: 17 additions & 17 deletions src/sage/algebras/letterplace/free_algebra_letterplace.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
"""
if not isinstance(R, MPolynomialRing_libsingular):
raise TypeError("a letterplace algebra must be provided by a polynomial ring of type %s" % MPolynomialRing_libsingular)
self.__ngens = R.ngens()
self._ngens = R.ngens()
if degrees is None:
varnames = R.variable_names()
self._nb_slackvars = 0
Expand All @@ -269,12 +269,12 @@ cdef class FreeAlgebra_letterplace(Algebra):
self._current_ring = make_letterplace_ring(R, 1)
self._degbound = 1
if degrees is None:
self._degrees = tuple([int(1)] * self.__ngens)
self._degrees = tuple([int(1)] * self._ngens)
else:
if (not isinstance(degrees, (tuple, list))) \
or len(degrees) != self.__ngens - self._nb_slackvars \
or len(degrees) != self._ngens - self._nb_slackvars \
or any(i <= 0 for i in degrees):
raise TypeError("the generator degrees must be given by a list or tuple of %d positive integers" % (self.__ngens - 1))
raise TypeError("the generator degrees must be given by a list or tuple of %d positive integers" % (self._ngens - 1))
self._degrees = tuple([int(i) for i in degrees])
self.set_degbound(max(self._degrees))
self._populate_coercion_lists_(coerce_list=[base_ring])
Expand Down Expand Up @@ -305,7 +305,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
sage: F.ngens()
3
"""
return self.__ngens - self._nb_slackvars
return self._ngens - self._nb_slackvars

def gen(self, i):
"""
Expand All @@ -327,17 +327,17 @@ cdef class FreeAlgebra_letterplace(Algebra):
sage: F.gen(2)
c
"""
if i >= self.__ngens - self._nb_slackvars:
raise ValueError("this free algebra only has %d generators" % (self.__ngens - self._nb_slackvars))
if i >= self._ngens - self._nb_slackvars:
raise ValueError("this free algebra only has %d generators" % (self._ngens - self._nb_slackvars))
if self._gens is not None:
return self._gens[i]
deg = self._degrees[i]
# self.set_degbound(deg)
p = self._current_ring.gen(i)
cdef int n
cdef int j = self.__ngens - 1
cdef int j = self._ngens - 1
for n in range(1, deg):
j += self.__ngens
j += self._ngens
p *= self._current_ring.gen(j)
return FreeAlgebraElement_letterplace(self, p)

Expand Down Expand Up @@ -413,7 +413,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
sage: FreeAlgebra(QQ, implementation='letterplace', names=['x']).is_commutative()
True
"""
return self.__ngens - self._nb_slackvars <= 1
return self._ngens - self._nb_slackvars <= 1

def is_field(self, proof=True):
"""
Expand All @@ -430,7 +430,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
sage: F.is_field()
False
"""
return (not (self.__ngens - self._nb_slackvars)) and self._base.is_field(proof=proof)
return (not (self._ngens - self._nb_slackvars)) and self._base.is_field(proof=proof)

def _repr_(self):
"""
Expand All @@ -446,7 +446,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
sage: F
Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
"""
return "Free Associative Unital Algebra on %d generators %s over %s" % (self.__ngens - self._nb_slackvars, self.gens(), self._base)
return "Free Associative Unital Algebra on %d generators %s over %s" % (self._ngens - self._nb_slackvars, self.gens(), self._base)

def _latex_(self):
r"""
Expand Down Expand Up @@ -586,7 +586,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
generated free abelian monoid.
In principle, this is correct, but it is not implemented, yet.>
"""
cdef int ngens = self.__ngens
cdef int ngens = self._ngens
cdef int nblocks = len(E) // ngens
cdef int i, j, base, exp, var_ind
cdef list out = []
Expand Down Expand Up @@ -618,7 +618,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
sage: latex(-(a*b*(z+1)-c)^2) # indirect doctest
\left(2 z + 1\right) a b a b + \left(z + 1\right) a b c + \left(z + 1\right) c a b - c c
"""
cdef int ngens = self.__ngens
cdef int ngens = self._ngens
cdef int nblocks = len(E) // ngens
cdef int i, j, base, exp, var_ind
cdef list out = []
Expand Down Expand Up @@ -678,7 +678,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
cdef list out = []
C = self.current_ring()
cdef FreeAlgebraElement_letterplace x
ngens = self.__ngens
ngens = self._ngens
cdef list G = [C(x._poly) for x in g]
from sage.groups.perm_gps.permgroup_named import CyclicPermutationGroup
CG = CyclicPermutationGroup(C.ngens())
Expand Down Expand Up @@ -811,7 +811,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
l = len(e)
break
cdef dict out = {}
self.set_degbound(l // self.__ngens)
self.set_degbound(l // self._ngens)
cdef Py_ssize_t n = self._current_ring.ngens()
for e, c in D.iteritems():
out[tuple(e) + (0,) * (n - l)] = c
Expand Down Expand Up @@ -896,7 +896,7 @@ cdef class FreeAlgebra_letterplace_libsingular():
self._commutative_ring = commutative_ring

def __init__(self, commutative_ring, degbound):
self.__ngens = commutative_ring.ngens() * degbound
self._ngens = commutative_ring.ngens() * degbound

def __dealloc__(self):
r"""
Expand Down
32 changes: 16 additions & 16 deletions src/sage/algebras/quatalg/quaternion_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1700,15 +1700,15 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra
x, y, z, w = v
cdef NumberFieldElement a = <NumberFieldElement>(parent._base(parent._a))
cdef NumberFieldElement b = <NumberFieldElement>(parent._base(parent._b))
fmpz_poly_set_ZZX(self.x, (<NumberFieldElement>x).__numerator)
fmpz_poly_set_ZZX(self.y, (<NumberFieldElement>y).__numerator)
fmpz_poly_set_ZZX(self.z, (<NumberFieldElement>z).__numerator)
fmpz_poly_set_ZZX(self.w, (<NumberFieldElement>w).__numerator)
fmpz_poly_set_ZZX(self.x, (<NumberFieldElement>x)._numerator)
fmpz_poly_set_ZZX(self.y, (<NumberFieldElement>y)._numerator)
fmpz_poly_set_ZZX(self.z, (<NumberFieldElement>z)._numerator)
fmpz_poly_set_ZZX(self.w, (<NumberFieldElement>w)._numerator)

ZZ_to_mpz(T1, &(<NumberFieldElement>x).__denominator)
ZZ_to_mpz(T2, &(<NumberFieldElement>y).__denominator)
ZZ_to_mpz(t3, &(<NumberFieldElement>z).__denominator)
ZZ_to_mpz(t4, &(<NumberFieldElement>w).__denominator)
ZZ_to_mpz(T1, &(<NumberFieldElement>x)._denominator)
ZZ_to_mpz(T2, &(<NumberFieldElement>y)._denominator)
ZZ_to_mpz(t3, &(<NumberFieldElement>z)._denominator)
ZZ_to_mpz(t4, &(<NumberFieldElement>w)._denominator)

mpz_lcm(self.d, T1, T2)
mpz_lcm(self.d, self.d, t3)
Expand All @@ -1724,10 +1724,10 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra
fmpz_poly_scalar_mul_mpz(self.z, self.z, t3)
fmpz_poly_scalar_mul_mpz(self.w, self.w, t4)

fmpz_poly_set_ZZX(self.a, a.__numerator) # we will assume that the denominator of a and b are 1
fmpz_poly_set_ZZX(self.b, b.__numerator)
fmpz_poly_set_ZZX(self.a, a._numerator) # we will assume that the denominator of a and b are 1
fmpz_poly_set_ZZX(self.b, b._numerator)

fmpz_poly_set_ZZX(self.modulus, (<NumberFieldElement>x).__fld_numerator.x) # and same for the modulus
fmpz_poly_set_ZZX(self.modulus, (<NumberFieldElement>x)._fld_numerator.x) # and same for the modulus

def __getitem__(self, int i):
"""
Expand Down Expand Up @@ -1756,17 +1756,17 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra
cdef NumberFieldElement item = el._new()

if i == 0:
fmpz_poly_get_ZZX(item.__numerator, self.x)
fmpz_poly_get_ZZX(item._numerator, self.x)
elif i == 1:
fmpz_poly_get_ZZX(item.__numerator, self.y)
fmpz_poly_get_ZZX(item._numerator, self.y)
elif i == 2:
fmpz_poly_get_ZZX(item.__numerator, self.z)
fmpz_poly_get_ZZX(item._numerator, self.z)
elif i == 3:
fmpz_poly_get_ZZX(item.__numerator, self.w)
fmpz_poly_get_ZZX(item._numerator, self.w)
else:
raise IndexError("quaternion element index out of range")

mpz_to_ZZ(&item.__denominator, self.d)
mpz_to_ZZ(&item._denominator, self.d)

return item

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/hopf_algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class HopfAlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
sage: A = C.example(); A # needs sage.groups
An example of Hopf algebra with basis: the group algebra of the
Dihedral group of order 6 as a permutation group over Rational Field
sage: A.__custom_name = "A" # needs sage.groups
sage: A.rename("A") # needs sage.groups
sage: A.category() # needs sage.groups
Category of finite dimensional hopf algebras with basis over Rational Field

Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/modules_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class ModulesWithBasis(CategoryWithAxiom_over_base_ring):

Let `X` and `Y` be two modules with basis. We can build `Hom(X,Y)`::

sage: X = CombinatorialFreeModule(QQ, [1,2]); X.__custom_name = "X" # needs sage.modules
sage: Y = CombinatorialFreeModule(QQ, [3,4]); Y.__custom_name = "Y" # needs sage.modules
sage: X = CombinatorialFreeModule(QQ, [1,2]); X.rename("X") # needs sage.modules
sage: Y = CombinatorialFreeModule(QQ, [3,4]); Y.rename("Y") # needs sage.modules
sage: H = Hom(X, Y); H # needs sage.modules
Set of Morphisms from X to Y
in Category of finite dimensional vector spaces with basis over Rational Field
Expand Down
9 changes: 4 additions & 5 deletions src/sage/combinat/cluster_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ def __init__(self, W, k, coxeter_element, algorithm):
self._W = W
self._w0 = w
self._k = k
if k == 1:
self.__custom_name = 'Cluster complex'
else:
self.__custom_name = 'Multi-cluster complex'

self.set_immutable()

Expand Down Expand Up @@ -271,7 +267,10 @@ def _repr_(self):
sage: ClusterComplex(['A', 2])._repr_()
"Cluster complex of type ['A', 2] with 5 vertices and 5 facets"
"""
name = self.__custom_name
if self._k == 1:
name = 'Cluster complex'
else:
name = 'Multi-cluster complex'
name += (' of type %s with %s vertices and %s facets'
% (self.cartan_type(), len(self.vertices()),
len(self._facets)))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/integer_lists/base.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ cdef class IntegerListsBackend():
cdef readonly min_part, max_part
cdef readonly min_slope, max_slope
cdef readonly Envelope floor, ceiling
cdef public dict __cached_methods # Support cached_method
cdef public dict _cached_methods # Support cached_method
1 change: 0 additions & 1 deletion src/sage/combinat/subword_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,6 @@ def __init__(self, Q, w, algorithm="inductive"):
SimplicialComplex.__init__(self, maximal_faces=Fs,
maximality_check=False,
category=cat)
self.__custom_name = 'Subword complex'
self._W = W
try:
T = W.coxeter_matrix().coxeter_type()
Expand Down
10 changes: 10 additions & 0 deletions src/sage/cpython/cython_metaclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ static CYTHON_INLINE int Sage_PyType_Ready(PyTypeObject* t)
if (r < 0)
return r;

#if PY_VERSION_HEX >= 0x03050000
// Cython 3 sets Py_TPFLAGS_HEAPTYPE before calling PyType_Ready,
// and resets just after the call. We need to reset it earlier,
// since otherwise the call to metaclass.__init__ below may have
// illegal memory accesses.
// See also:
// https://github.com/cython/cython/issues/3603
t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
#endif

/* Set or get metaclass (the type of t) */
PyTypeObject* metaclass;

Expand Down
9 changes: 8 additions & 1 deletion src/sage/cpython/cython_metaclass.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ file if you are using one).

In the extension type (a.k.a. ``cdef class``) for which you want to
define a metaclass, define a method ``__getmetaclass__`` with a single
unused argument. This method should return a type to be used as
unused argument, and turn off the Cython directive
``always_allow_keywords``. This method should return a type to be used as
Comment on lines -22 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bugfix or a performance hack? If the former, what happens if always_allow_keywords(False) is not used?

For the record, this commit (55b088a) is only changing documentation and doctests, the actual change happens in src/sage/structure/element.pyx in commit 7e011a7, which is the only place where this metaclass magic is used in sagemath.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code currently requires a METH_NOARGS method (in src/sage/cpython/cython_metaclass.h), and this is the way make one in Cython 3. Not having this results in the error PyMethodDescr_CallSelf requires a method without arguments. I think the code could be changed to handle other types of methods, but I did not look deeper into that.

Relevant Cython changelog item:

No/single argument functions now accept keyword arguments by default in order to comply with Python semantics. The marginally faster calling conventions METH_NOARGS and METH_O that reject keyword arguments are still available with the directive @cython.always_allow_keywords(False). (Github issue #3090)

metaclass:

.. code-block:: cython

cimport cython
cimport sage.cpython.cython_metaclass
cdef class MyCustomType():
@cython.always_allow_keywords(False)
def __getmetaclass__(_):
from foo import MyMetaclass
return MyMetaclass
Expand Down Expand Up @@ -63,8 +66,10 @@ EXAMPLES::

sage: cython( # needs sage.misc.cython
....: '''
....: cimport cython
....: cimport sage.cpython.cython_metaclass
....: cdef class MyCustomType():
....: @cython.always_allow_keywords(False)
....: def __getmetaclass__(_):
....: class MyMetaclass(type):
....: def __init__(*args):
Expand Down Expand Up @@ -101,8 +106,10 @@ returns a non-type::

sage: cython( # needs sage.misc.cython
....: '''
....: cimport cython
....: cimport sage.cpython.cython_metaclass
....: cdef class MyCustomType():
....: @cython.always_allow_keywords(False)
....: def __getmetaclass__(_):
....: return 2
....: ''')
Expand Down
2 changes: 1 addition & 1 deletion src/sage/cpython/getattr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ cpdef getattr_from_other_class(self, cls, name):

Caveat: lazy attributes work with extension types only
if they allow attribute assignment or have a public attribute
``__cached_methods`` of type ``<dict>``. This condition
``_cached_methods`` of type ``<dict>``. This condition
is satisfied, e.g., by any class that is derived from
:class:`Parent`::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from .polyhedron_face_lattice cimport PolyhedronFaceLattice

@cython.final
cdef class CombinatorialPolyhedron(SageObject):
cdef public dict __cached_methods
cdef public dict _cached_methods

# Do not assume any of those attributes to be initialized, use the corresponding methods instead.
cdef tuple _Vrep # the names of VRep, if they exist
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/permgroup_element.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
cpdef PermutationGroupElement _generate_new_GAP(self, old)
cpdef _gap_list(self)
cpdef domain(self)
cdef public __custom_name
cdef public _SageObject__custom_name
cpdef list _act_on_list_on_position(self, list x)
cpdef ClonableIntArray _act_on_array_on_position(self, ClonableIntArray x)
cpdef ETuple _act_on_etuple_on_position(self, ETuple x)
7 changes: 2 additions & 5 deletions src/sage/interfaces/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,11 +1169,8 @@ def __repr__(self):
s = cr
else:
s = self._repr_()
if self._name in s:
try:
s = s.replace(self._name, getattr(self, '__custom_name'))
except AttributeError:
pass
if self._name in s and self.get_custom_name() is not None:
s = s.replace(self._name, self.get_custom_name())
if cr:
self._cached_repr = s
return s
Expand Down
4 changes: 2 additions & 2 deletions src/sage/interfaces/singular.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,8 +1400,8 @@ def _repr_(self):
"""
s = super(SingularElement, self)._repr_()
if self._name in s:
if (not hasattr(self, "__custom_name")) and self.type() == 'matrix':
s = self.parent().eval('pmat(%s,20)'%(self.name()))
if self.get_custom_name() is None and self.type() == 'matrix':
s = self.parent().eval('pmat(%s,20)' % (self.name()))
return s

def __copy__(self):
Expand Down
Loading
Loading