Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Menu
Projects
Groups
Snippets
Get a free trial
Sign up
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
SageMath
SageMath Developers
tracmirror
Compare Revisions
develop...u/jdemeyer/ticket/22747
Commits (4)
Move Set_PythonType to a new file
· 7e7daef3
Jeroen Demeyer
authored
Jul 12, 2018
7e7daef3
Some preparations for binding=True
· 742e1c9b
Jeroen Demeyer
authored
Jul 12, 2018
742e1c9b
Compile Cython code with binding=True
· c5a8bd38
Jeroen Demeyer
authored
Jun 06, 2017
c5a8bd38
Sage library fixes for binding=True
· d9620409
Jeroen Demeyer
authored
Apr 03, 2017
d9620409
Hide whitespace changes
Inline
Side-by-side
src/doc/en/developer/coding_in_cython.rst
View file @
d9620409
...
...
@@ -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',))
(<
cy
function make_integer
at ...
>, ('5',))
sage: t[0](*t[1])
5
sage: loads(dumps(n)) == n
...
...
src/doc/en/prep/Programming.rst
View file @
d9620409
...
...
@@ -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!
...
...
src/doc/en/prep/Symbolics-and-Basic-Plotting.rst
View file @
d9620409
...
...
@@ -199,7 +199,7 @@ This is a good place for a few reminders of basic help.
::
sage: z.simplify
<b
uilt-in
method simplify of
sage.symbolic.expression.Expression object at ...
>
<b
ound
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.
...
...
src/doc/en/reference/sets/index.rst
View file @
d9620409
...
...
@@ -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
---------------
...
...
src/doc/en/thematic_tutorials/coercion_and_categories.rst
View file @
d9620409
...
...
@@ -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::
...
...
src/sage/__init__.py
View file @
d9620409
...
...
@@ -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::
...
...
src/sage/arith/misc.py
View file @
d9620409
...
...
@@ -1870,9 +1870,9 @@ def get_gcd(order):
EXAMPLES::
sage: sage.arith.misc.get_gcd(4000)
<b
uilt-in
method gcd_int of sage.rings.fast_arith.arith_int object at ...>
<b
ound
method
arith_int.
gcd_int of
<
sage.rings.fast_arith.arith_int object at ...>
>
sage: sage.arith.misc.get_gcd(400000)
<b
uilt-in
method gcd_longlong of sage.rings.fast_arith.arith_llong object at ...>
<b
ound
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)
<b
uilt-in
method inverse_mod_int of sage.rings.fast_arith.arith_int object at ...>
<b
ound
method
arith_int.
inverse_mod_int of
<
sage.rings.fast_arith.arith_int object at ...>
>
sage: sage.arith.misc.get_inverse_mod(600000)
<b
uilt-in
method inverse_mod_longlong of sage.rings.fast_arith.arith_llong object at ...>
<b
ound
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 ...>
"""
...
...
src/sage/categories/category.py
View file @
d9620409
...
...
@@ -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
):
"""
...
...
src/sage/categories/homset.py
View file @
d9620409
...
...
@@ -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
...
...
src/sage/categories/map.pyx
View file @
d9620409
...
...
@@ -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.s
tructure.parent
cimport
Set_PythonType
from
sage.s
ets.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
...
...
src/sage/categories/modules.py
View file @
d9620409
...
...
@@ -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::
...
...
src/sage/categories/primer.py
View file @
d9620409
...
...
@@ -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::
...
...
src/sage/combinat/sf/classical.py
View file @
d9620409
...
...
@@ -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>
<
cy
function t_SCHUR_POWSYM_symmetrica
at ...
>
The following checks if the bug described in :trac:`15312` is fixed. ::
...
...
src/sage/combinat/words/alphabet.py
View file @
d9620409
...
...
@@ -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.s
tructure.parent
import
Set_PythonType
from
sage.s
ets.pythonclass
import
Set_PythonType
return
Set_PythonType
(
object
)
raise
ValueError
(
"unable to construct an alphabet from the given parameters"
)
...
...
src/sage/finance/time_series.pyx
View file @
d9620409
...
...
@@ -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))
(<
cy
function 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
...
...
src/sage/graphs/strongly_regular_db.pyx
View file @
d9620409
...
...
@@ -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]
[<
cy
function 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)
...
...
src/sage/interfaces/sage0.py
View file @
d9620409
...
...
@@ -556,7 +556,7 @@ class SageFunction(FunctionElement):
EXAMPLES::
sage: sage0(4).gcd
<b
uilt-in
method
gcd of sage.rings.integer.Integer object at 0x...
>
<b
ound
method
Integer.gcd of 4
>
"""
return
str
(
self
.
_obj
.
parent
().
eval
(
'%s.%s'
%
(
self
.
_obj
.
_name
,
self
.
_name
)))
...
...
src/sage/libs/singular/ring.pyx
View file @
d9620409
...
...
@@ -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>
<
cy
function poison_currRing
at ...
>
sage: sys.settrace(previous_trace_func) # switch it off again
"""
global
currRing
...
...
src/sage/misc/c3_controlled.pyx
View file @
d9620409
...
...
@@ -1090,7 +1090,7 @@ class HierarchyElement(object, metaclass=ClasscallMetaclass):
sage: x._bases
[5, 2]
sage: x._key
<
built-in
function identity>
<
cy
function identity
at ...
>
sage: x._key(10)
10
...
...
src/sage/misc/fpickle.pyx
View file @
d9620409
# 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>, ...)
(<
cy
function 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>, ...)
(<
cy
function code_ctor
at ...
>, ...)
"""
if
co
.
co_freevars
or
co
.
co_cellvars
:
raise
ValueError
(
"Cannot pickle code objects from closures"
)
...
...
Prev
1
2
3
Next