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

Commit

Permalink
Merge #26254
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jul 25, 2022
2 parents 7f71494 + 02d6282 commit bca67b0
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2114,9 +2114,9 @@ def get_gcd(order):
EXAMPLES::
sage: sage.arith.misc.get_gcd(4000)
<built-in method gcd_int of sage.rings.fast_arith.arith_int object at ...>
<bound method arith_int.gcd_int of <sage.rings.fast_arith.arith_int object at ...>
sage: sage.arith.misc.get_gcd(400000)
<built-in method gcd_longlong of sage.rings.fast_arith.arith_llong object at ...>
<bound method arith_llong.gcd_longlong of <sage.rings.fast_arith.arith_llong object at ...>
sage: sage.arith.misc.get_gcd(4000000000)
<function gcd at ...>
"""
Expand All @@ -2136,9 +2136,9 @@ def get_inverse_mod(order):
EXAMPLES::
sage: sage.arith.misc.get_inverse_mod(6000)
<built-in method inverse_mod_int of sage.rings.fast_arith.arith_int object at ...>
<bound method arith_int.inverse_mod_int of <sage.rings.fast_arith.arith_int object at ...>
sage: sage.arith.misc.get_inverse_mod(600000)
<built-in method inverse_mod_longlong of sage.rings.fast_arith.arith_llong object at ...>
<bound method arith_llong.inverse_mod_longlong of <sage.rings.fast_arith.arith_llong object at ...>
sage: sage.arith.misc.get_inverse_mod(6000000000)
<function inverse_mod at ...>
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/strongly_regular_db.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ def is_RSHCD(int v,int k,int l,int mu):

sage: from sage.graphs.strongly_regular_db import is_RSHCD
sage: t = is_RSHCD(64,27,10,12); t
[<built-in function SRG_from_RSHCD>, 64, 27, 10, 12]
[<cyfunction SRG_from_RSHCD at ...>, 64, 27, 10, 12]
sage: g = t[0](*t[1:]); g
Graph on 64 vertices
sage: g.is_strongly_regular(parameters=True)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/interfaces/sage0.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def _repr_(self):
EXAMPLES::
sage: sage0(4).gcd
<built-in method gcd of sage.rings.integer.Integer object at 0x...>
<bound method PrincipalIdealDomainElement.gcd of 4>
"""
return str(self._obj.parent().eval('%s.%s' % (self._obj._name,
self._name)))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/singular/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ cpdef poison_currRing(frame, event, arg):
sage: from sage.libs.singular.ring import poison_currRing
sage: sys.settrace(poison_currRing)
sage: sys.gettrace()
<built-in function poison_currRing>
<cyfunction poison_currRing at ...>
sage: sys.settrace(previous_trace_func) # switch it off again
"""
global currRing
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/c3_controlled.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ class HierarchyElement(object, metaclass=ClasscallMetaclass):
sage: x._bases
[5, 2]
sage: x._key
<built-in function identity>
<cyfunction identity at ...>
sage: x._key(10)
10
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/finite_rings/hom_finite_field.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ cdef class FiniteFieldHomomorphism_generic(RingHomomorphism_im_gens):
sage: Frob = k.frobenius_endomorphism()
sage: embed = Frob.fixed_field()[1]
sage: embed.__reduce__() # indirect doctest
(<built-in function unpickle_map>,
(<cyfunction unpickle_map at ...>,
(<class 'sage.rings.finite_rings.hom_prime_finite_field.FiniteFieldHomomorphism_prime'>,
Set of field embeddings from Finite Field of size 5 to Finite Field in t of size 5^3,
{},
Expand Down Expand Up @@ -835,7 +835,7 @@ cdef class FrobeniusEndomorphism_finite_field(FrobeniusEndomorphism_generic):
sage: k.<t> = GF(5^3)
sage: Frob = k.frobenius_endomorphism(2)
sage: Frob.__reduce__() # indirect doctest
(<built-in function unpickle_map>,
(<cyfunction unpickle_map at ...>,
(<class 'sage.rings.finite_rings.hom_finite_field_givaro.FrobeniusEndomorphism_givaro'>,
Automorphism group of Finite Field in t of size 5^3,
{},
Expand Down
2 changes: 1 addition & 1 deletion src/sage/structure/list_clone.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ cdef class ClonableArray(ClonableElement):
sage: loads(dumps(el))
[1, 2, 4]
sage: t = el.__reduce__(); t
(<built-in function _make_array_clone>,
(<cyfunction _make_array_clone at ...>,
(<class 'sage.structure.list_clone_demo.IncreasingArray'>,
<sage.structure.list_clone_demo.IncreasingArrays_with_category object at ...>,
[1, 2, 4],
Expand Down
1 change: 0 additions & 1 deletion src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6349,7 +6349,6 @@ cdef class Expression(Expression_abc):
sage: type(u._unpack_operands()[0])
<... 'tuple'>
"""
from sage.symbolic.expression import unpack_operands
return unpack_operands(self)

def operands(self):
Expand Down
17 changes: 12 additions & 5 deletions src/sage/symbolic/function.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ is attempted, and after that ``sin()`` which succeeds::
from sage.structure.sage_object cimport SageObject
from sage.structure.element cimport Element, parent, Expression
from sage.misc.lazy_attribute import lazy_attribute
from .expression import (
call_registered_function, find_registered_function, register_or_update_function,
get_sfunction_from_hash
)
from .expression import get_sfunction_from_serial as get_sfunction_from_serial

from sage.structure.coerce cimport (coercion_model,
py_scalar_to_element, is_numpy_type, is_mpmath_type)
Expand Down Expand Up @@ -263,6 +258,8 @@ cdef class Function(SageObject):
f(x)
"""
from .expression import register_or_update_function

self._serial = register_or_update_function(self, self._name, self._latex_name,
self._nargs, self._evalf_params_first,
False)
Expand Down Expand Up @@ -544,6 +541,8 @@ cdef class Function(SageObject):
if not isinstance(a, Expression):
raise TypeError("arguments must be symbolic expressions")

from .expression import call_registered_function

return call_registered_function(self._serial, self._nargs, args, hold,
not symbolic_input, SR)

Expand Down Expand Up @@ -838,13 +837,17 @@ cdef class GinacFunction(BuiltinFunction):
preserved_arg=preserved_arg, alt_name=alt_name)

cdef _is_registered(self):
from .expression import find_registered_function, get_sfunction_from_serial

# Since this is function is defined in C++, it is already in
# ginac's function registry
fname = self._ginac_name if self._ginac_name is not None else self._name
self._serial = find_registered_function(fname, self._nargs)
return bool(get_sfunction_from_serial(self._serial))

cdef _register_function(self):
from .expression import register_or_update_function

# We don't need to add anything to GiNaC's function registry
# However, if any custom methods were provided in the python class,
# we should set the properties of the function_options object
Expand Down Expand Up @@ -1092,6 +1095,8 @@ cdef class BuiltinFunction(Function):
sage: loads(dumps(cot)) == cot # trac #15138
True
"""
from .expression import find_registered_function, get_sfunction_from_serial

# check if already defined
cdef unsigned int serial

Expand Down Expand Up @@ -1189,6 +1194,8 @@ cdef class SymbolicFunction(Function):
evalf_params_first)

cdef _is_registered(SymbolicFunction self):
from .expression import get_sfunction_from_hash

# see if there is already a SymbolicFunction with the same state
cdef long myhash = self._hash_()
cdef SymbolicFunction sfunc = get_sfunction_from_hash(myhash)
Expand Down
7 changes: 5 additions & 2 deletions src/sage/symbolic/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ from sage.structure.coerce cimport is_numpy_type
import sage.rings.abc
from sage.rings.integer_ring import ZZ

# is_SymbolicVariable used to be defined here; re-export it
from sage.symbolic.expression import _is_SymbolicVariable as is_SymbolicVariable
# is_SymbolicVariable used to be defined here; re-export it here lazily
cpdef bint is_SymbolicVariable(x):
from sage.symbolic.expression import _is_SymbolicVariable

return _is_SymbolicVariable(x)

import keyword
import operator
Expand Down
5 changes: 5 additions & 0 deletions src/sage_setup/cython_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def compiler_directives(profile: bool):
auto_pickle=False,
# Do not create __test__ dictionary automatically from docstrings
autotestdict=False,
# When enabled, functions will bind to an instance when looked up as a
# class attribute (hence the name) and will emulate the attributes of
# Python functions, including introspections like argument names and
# annotations
binding=True,
# Do not check for division by 0 (this is about 35% quicker than with check)
cdivision=True,
# Embed a textual copy of the call signature in the docstring (to support tools like IPython)
Expand Down

0 comments on commit bca67b0

Please sign in to comment.