Commits (4)
......@@ -184,7 +184,7 @@ original object. As an example, the following code snippet is the
sage: n = 5
sage: t = n.__reduce__(); t
(<built-in function make_integer>, ('5',))
(<cyfunction make_integer at ...>, ('5',))
sage: t[0](*t[1])
5
sage: loads(dumps(n)) == n
......
......@@ -102,14 +102,17 @@ Then we do the row\-reduced echelon form.
It is very important to keep in the parentheses.
.. note::
Things that would be legal without them would be called 'attributes',
but Sage prefers stylistically to hide them, since math is made of functions
and not elements of sets. Or so a category\-theorist would say.
::
Things that would be legal without them would be called 'attributes',
but Sage prefers stylistically to hide them, since math is made of
functions and not elements of sets.
Or so a category-theorist would say.
::
sage: A.det # Won't work
<built-in method det of sage.matrix.matrix_integer_dense.Matrix_integer_dense object at ...>
sage: A.det # Won't work
<bound method Matrix_integer_dense.det of [1 2]
[3 4]>
This is so useful because we can use the 'tab' key, remember!
......
......@@ -199,7 +199,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.
......
......@@ -18,6 +18,7 @@ Set Constructions
sage/sets/finite_set_maps
sage/sets/finite_set_map_cy
sage/sets/totally_ordered_finite_set
sage/sets/pythonclass
Sets of Numbers
---------------
......
......@@ -452,7 +452,7 @@ And indeed, ``MS2`` has *more* methods than ``MS1``::
sage: len([s for s in dir(MS1) if inspect.ismethod(getattr(MS1,s,None))])
79
sage: len([s for s in dir(MS2) if inspect.ismethod(getattr(MS2,s,None))])
118
237
This is because the class of ``MS2`` also inherits from the parent
class for algebras::
......
......@@ -35,10 +35,16 @@ def isfunction(obj):
sage: from sage.categories.coercion_methods import _mul_parent
sage: isfunction(_mul_parent)
True
sage: from sage.structure.richcmp import rich_to_bool
sage: isfunction(rich_to_bool)
True
sage: isfunction(Integer.digits) # unbound method
False
sage: isfunction(Integer(1).digits) # bound method
False
sage: from sage.geometry.point_collection import PointCollection
sage: isfunction(PointCollection.output_format) # static method
True
Verify that ipywidgets can correctly determine signatures of Cython
functions::
......
......@@ -1870,9 +1870,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 ...>
"""
......@@ -1891,9 +1891,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 ...>
"""
......
......@@ -2214,7 +2214,7 @@ class Category(UniqueRepresentation, SageObject):
"""
return self
_flatten_categories = _flatten_categories
_flatten_categories = staticmethod(_flatten_categories) # a cythonised helper
@staticmethod
def _sort(categories):
......@@ -2263,7 +2263,7 @@ class Category(UniqueRepresentation, SageObject):
"""
return tuple(sorted(categories, key=category_sort_key, reverse=True))
_sort_uniq = _sort_uniq # a cythonised helper
_sort_uniq = staticmethod(_sort_uniq) # a cythonised helper
def __and__(self, other):
"""
......
......@@ -273,8 +273,9 @@ def Hom(X, Y, category=None, check=True):
Facade parents over plain Python types are supported::
sage: R = sage.structure.parent.Set_PythonType(int)
sage: S = sage.structure.parent.Set_PythonType(float)
sage: from sage.sets.pythonclass import Set_PythonType
sage: R = Set_PythonType(int)
sage: S = Set_PythonType(float)
sage: Hom(R, S)
Set of Morphisms from Set of Python objects of class 'int' to Set of Python objects of class 'float' in Category of sets
......
......@@ -25,7 +25,7 @@ from . import homset
import weakref
from sage.ext.stdsage cimport HAS_DICTIONARY
from sage.arith.power cimport generic_power
from sage.structure.parent cimport Set_PythonType
from sage.sets.pythonclass cimport Set_PythonType
from sage.misc.constant_function import ConstantFunction
from sage.misc.superseded import deprecated_function_alias
from sage.structure.element cimport parent
......
......@@ -589,6 +589,7 @@ class Modules(Category_module):
:meth:`sage.structure.category_object.CategoryObject.base_ring`::
sage: H.base_ring.__module__
'sage.structure.category_object'
Here we call it directly::
......
......@@ -913,12 +913,10 @@ Where do all the operations on ``S`` and its elements come from?
sage: x = S('a')
``_repr_`` is a technical method which comes with the data structure
(:class:`ElementWrapper`); since it's implemented in Cython, we need
to use Sage's introspection tools to recover where it's implemented::
(:class:`ElementWrapper`)::
sage: x._repr_.__module__
sage: sage.misc.sageinspect.sage_getfile(x._repr_)
'.../sage/structure/element_wrapper.pyx'
'sage.structure.element_wrapper'
``_pow_int`` is a generic method for all finite semigroups::
......
......@@ -51,7 +51,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. ::
......
......@@ -265,7 +265,7 @@ def build_alphabet(data=None, names=None, name=None):
# Alphabet(**nothing**)
if data is None: # name is also None
from sage.structure.parent import Set_PythonType
from sage.sets.pythonclass import Set_PythonType
return Set_PythonType(object)
raise ValueError("unable to construct an alphabet from the given parameters")
......
......@@ -45,8 +45,10 @@ AUTHOR:
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import absolute_import
cimport cython
from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_AsString
from libc.math cimport exp, floor, log, pow, sqrt
from libc.string cimport memcpy
......@@ -177,7 +179,7 @@ cdef class TimeSeries:
sage: v = finance.TimeSeries([1,-3.5])
sage: v.__reduce__()
(<built-in function unpickle_time_series_v1>, (..., 2))
(<cyfunction unpickle_time_series_v1 at ...>, (..., 2))
sage: loads(dumps(v)) == v
True
......@@ -2562,6 +2564,8 @@ cdef new_time_series(Py_ssize_t length):
t._values = <double*> sig_malloc(sizeof(double)*length)
return t
@cython.binding(True)
def unpickle_time_series_v1(bytes v, Py_ssize_t n):
"""
Version 1 unpickle method.
......@@ -2590,8 +2594,6 @@ def unpickle_time_series_v1(bytes v, Py_ssize_t n):
return t
def autoregressive_fit(acvs):
r"""
Given a sequence of lagged autocovariances of length `M` produce
......
......@@ -1148,7 +1148,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)
......
......@@ -556,7 +556,7 @@ class SageFunction(FunctionElement):
EXAMPLES::
sage: sage0(4).gcd
<built-in method gcd of sage.rings.integer.Integer object at 0x...>
<bound method Integer.gcd of 4>
"""
return str(self._obj.parent().eval('%s.%s' % (self._obj._name,
self._name)))
......
......@@ -655,7 +655,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
......
......@@ -1090,7 +1090,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
......
# cython: old_style_globals=True
# cython: binding=True
"""
Function pickling
......@@ -20,7 +21,7 @@ def code_ctor(*args):
sage: def foo(a,b,c=10): return a+b+c
sage: sage.misc.fpickle.reduce_code(foo.__code__)
(<built-in function code_ctor>, ...)
(<cyfunction code_ctor at ...>, ...)
sage: unpickle_function(pickle_function(foo))
<function foo at ...>
"""
......@@ -33,7 +34,7 @@ def reduce_code(co):
sage: def foo(N): return N+1
sage: sage.misc.fpickle.reduce_code(foo.__code__)
(<built-in function code_ctor>, ...)
(<cyfunction code_ctor at ...>, ...)
"""
if co.co_freevars or co.co_cellvars:
raise ValueError("Cannot pickle code objects from closures")
......