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

Commit

Permalink
Rebase sage autodoc
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Nov 8, 2022
1 parent c3028e7 commit 94a9718
Show file tree
Hide file tree
Showing 28 changed files with 2,211 additions and 892 deletions.
2 changes: 1 addition & 1 deletion src/doc/en/prep/Programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ It is very important to keep in the parentheses.
::

sage: A.det # Won't work
<built-in method det of sage.matrix.matrix_integer_dense.Matrix_integer_dense object at ...>
<bound method Matrix.det of ...>

This is so useful because we can use the 'tab' key, remember!

Expand Down
2 changes: 1 addition & 1 deletion src/doc/en/prep/Symbolics-and-Basic-Plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ This is a good place for a few reminders of basic help.
::

sage: z.simplify
<built-in method simplify of sage.symbolic.expression.Expression object at ...>
<bound method Expression.simplify of -((x + 1)*sqrt(x - 1) - (x - 1)^(3/2))/sqrt((x + 1)*(x - 1))>

Finally, recall that you can get nicely typeset versions of the output
in several ways.
Expand Down
8 changes: 4 additions & 4 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2163,9 +2163,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 @@ -2185,9 +2185,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/combinat/root_system/cartan_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ def classical(self):
We check that :meth:`classical`,
:meth:`sage.combinat.root_system.cartan_type.CartanType_crystallographic.dynkin_diagram`,
and :meth:`.special_node` are consistent::
and :meth:`special_node` are consistent::
sage: for ct in CartanType.samples(affine = True):
....: g1 = ct.classical().dynkin_diagram()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/sf/classical.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def init():
sage: sage.combinat.sf.classical.conversion_functions = {}
sage: init()
sage: sage.combinat.sf.classical.conversion_functions[('Schur', 'powersum')]
<built-in function t_SCHUR_POWSYM_symmetrica>
<cyfunction t_SCHUR_POWSYM_symmetrica at ...>
The following checks if the bug described in :trac:`15312` is fixed. ::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/finance/option.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def black_scholes(double spot_price, double strike_price, double time_to_maturit
sage: finance.black_scholes
doctest:warning...
DeprecationWarning: the package sage.finance is deprecated...
<built-in function black_scholes>
<cyfunction black_scholes at ...>
sage: finance.black_scholes(42, 40, 0.5, 0.1, 0.2, 'call') # abs tol 1e-10
4.759422392871532
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 @@ -1154,7 +1154,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/manifolds/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -2206,7 +2206,7 @@ class options(GlobalOptions):
sage: M.options._reset()
"""
NAME = 'manifolds'
module = 'sage.manifolds'
module = 'sage.manifolds.manifold'
option_class = 'TopologicalManifold'
textbook_output = dict(default=True,
description='textbook-like output instead of the Pynac output for derivatives',
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: 1 addition & 3 deletions src/sage/misc/sagedoc_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def process_docstring_aliases(app, what, name, obj, options, docstringlines):
"""
Change the docstrings for aliases to point to the original object.
"""

basename = name.rpartition('.')[2]
if hasattr(obj, '__name__') and obj.__name__ != basename:
docstringlines[:] = ['See :obj:`%s`.' % name]
Expand Down Expand Up @@ -146,9 +147,6 @@ def apply(self):
node.rawsource = source
node[:] = [nodes.Text(source)]

from sage.misc.sageinspect import sage_getargspec
autodoc_builtin_argspec = sage_getargspec

# This is only used by sage.misc.sphinxify
def setup(app):
app.connect('autodoc-process-docstring', process_docstring_cython)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def is_function_or_cython_function(obj):
sage: is_function_or_cython_function(_mul_parent)
True
sage: is_function_or_cython_function(Integer.digits) # unbound method
False
True
sage: is_function_or_cython_function(Integer(1).digits) # bound method
False
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/rings/function_field/function_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
sage: TestSuite(S).run() # long time (4s)
Global function fields
----------------------
======================
A global function field in Sage is an extension field of a rational function field
over a *finite* constant field by an irreducible separable polynomial over the
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/polynomial/laurent_polynomial.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3308,12 +3308,12 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial):
to variables supplied in args.
Multiple variables and iteration counts may be supplied; see
documentation for the global derivative() function for more
documentation for the global :func:`derivative` function for more
details.
.. SEEALSO::
:meth:`_derivative`
:meth:`_derivative`
EXAMPLES::
Expand All @@ -3336,7 +3336,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial):
respect to the given variable.
If var is among the generators of this ring, the derivative
is with respect to the generator. Otherwise, _derivative(var) is called
is with respect to the generator. Otherwise, ``_derivative(var)`` is called
recursively for each coefficient of this polynomial.
.. SEEALSO:: :meth:`derivative`
Expand Down
8 changes: 4 additions & 4 deletions src/sage/sets/disjoint_set.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,14 @@ cdef class DisjointSet_of_integers(DisjointSet_class):
sage: d = DisjointSet(5)
sage: d.__reduce__()
(<built-in function DisjointSet>, (5,), [0, 1, 2, 3, 4])
(<cyfunction DisjointSet at ...>, (5,), [0, 1, 2, 3, 4])
::
sage: d.union(2,4)
sage: d.union(1,3)
sage: d.__reduce__()
(<built-in function DisjointSet>, (5,), [0, 1, 2, 1, 2])
(<cyfunction DisjointSet at ...>, (5,), [0, 1, 2, 1, 2])
"""
return DisjointSet, (self._nodes.degree,), self.__getstate__()

Expand Down Expand Up @@ -674,7 +674,7 @@ cdef class DisjointSet_of_hashables(DisjointSet_class):
{{0}, {1}, {2}, {3}, {4}}
sage: d = _
sage: d.__reduce__()
(<built-in function DisjointSet>,
(<cyfunction DisjointSet at ...>,
([0, 1, 2, 3, 4],),
[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)])
Expand All @@ -683,7 +683,7 @@ cdef class DisjointSet_of_hashables(DisjointSet_class):
sage: d.union(2,4)
sage: d.union(1,3)
sage: d.__reduce__()
(<built-in function DisjointSet>,
(<cyfunction DisjointSet at ...>,
([0, 1, 2, 3, 4],),
[(0, 0), (1, 1), (2, 2), (3, 1), (4, 2)])
"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/structure/category_object.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ cdef class CategoryObject(SageObject):
sage: F.base_ring()
Integer Ring
sage: F.__class__.base_ring
<method 'base_ring' of 'sage.structure.category_object.CategoryObject' objects>
<cyfunction CategoryObject.base_ring at ...>
Note that the coordinates of the elements of a module can lie
in a bigger ring, the ``coordinate_ring``::
Expand All @@ -591,15 +591,15 @@ cdef class CategoryObject(SageObject):
sage: F.base_ring()
Rational Field
sage: F.__class__.base_ring
<method 'base_ring' of 'sage.structure.category_object.CategoryObject' objects>
<cyfunction CategoryObject.base_ring at ...>
sage: E = CombinatorialFreeModule(ZZ, [1,2,3])
sage: F = CombinatorialFreeModule(ZZ, [2,3,4])
sage: H = Hom(E, F)
sage: H.base_ring()
Integer Ring
sage: H.__class__.base_ring
<method 'base_ring' of 'sage.structure.category_object.CategoryObject' objects>
<cyfunction CategoryObject.base_ring at ...>
.. TODO::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/structure/factory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ cdef class UniqueFactory(SageObject):
sage: a = test_factory(1, 2)
Making object (1, 2)
sage: test_factory.reduce_data(a)
(<built-in function generic_factory_unpickle>,
(<cyfunction generic_factory_unpickle at ...>,
(<sage.structure.test_factory.UniqueFactoryTester object at ...>,
(...),
(1, 2),
Expand Down
2 changes: 1 addition & 1 deletion src/sage/structure/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ def __eq__(self, other):
sage: Partitions.options == Tableaux.options
False
"""
return self.__getstate__() == other.__getstate__()
return isinstance(other, GlobalOptions) and self.__getstate__() == other.__getstate__()

def _add_option(self, option, specifications):
r"""
Expand Down
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -1720,7 +1720,7 @@ cdef class ClonableIntArray(ClonableElement):
sage: loads(dumps(el))
[1, 2, 4]
sage: t = el.__reduce__(); t
(<built-in function _make_int_array_clone>,
(<cyfunction _make_int_array_clone at ...>,
(<class 'sage.structure.list_clone_demo.IncreasingIntArray'>,
<sage.structure.list_clone_demo.IncreasingIntArrays_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 @@ -6363,7 +6363,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 @@ -1094,6 +1097,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 @@ -1191,6 +1196,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
2 changes: 1 addition & 1 deletion src/sage/symbolic/getitem_impl.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ cdef class OperandsWrapper(SageObject):
TESTS::
sage: (x^2).op.__reduce__()
(<built-in function restore_op_wrapper>, (x^2,))
(<cyfunction restore_op_wrapper at ...>, (x^2,))
sage: loads(dumps((x^2).op))
Operands of x^2
"""
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

0 comments on commit 94a9718

Please sign in to comment.