Skip to content

Commit c18bea3

Browse files
author
Release Manager
committed
gh-40341: Set cython directive `binding=True` <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Continuation of #26254. This is needed for better integration of Cython functions and thereby unlocks a few further documentation improvements (#27578, #30884, #31309, ...). Moreover, `binding=True` is the default in Cython 3. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies - #40357 <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40341 Reported by: Tobias Diez Reviewer(s): David Coudert
2 parents a47ad86 + b8ba5f9 commit c18bea3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+244
-184
lines changed

src/doc/en/prep/Programming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ It is very important to keep in the parentheses.
109109
::
110110

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

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

src/doc/en/prep/Symbolics-and-Basic-Plotting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ This is a good place for a few reminders of basic help.
178178
::
179179

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

183183
Finally, recall that you can get nicely typeset versions of the output
184184
in several ways.

src/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ add_project_arguments('-I', meson.current_build_dir(), language: 'cython')
219219
# Add global compiler flags
220220
add_project_arguments('-X auto_pickle=False', language: 'cython')
221221
add_project_arguments('-X autotestdict=False', language: 'cython')
222-
add_project_arguments('-X binding=False', language: 'cython')
222+
add_project_arguments('-X binding=True', language: 'cython')
223223
add_project_arguments('-X c_api_binop_methods=True', language: 'cython')
224224
add_project_arguments('-X cdivision=True', language: 'cython')
225225
add_project_arguments('-X cpow=True', language: 'cython')

src/sage/arith/misc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,9 +2236,9 @@ def get_gcd(order):
22362236
EXAMPLES::
22372237
22382238
sage: sage.arith.misc.get_gcd(4000)
2239-
<built-in method gcd_int of sage.rings.fast_arith.arith_int object at ...>
2239+
<bound method arith_int.gcd_int of <sage.rings.fast_arith.arith_int object at ...>
22402240
sage: sage.arith.misc.get_gcd(400000)
2241-
<built-in method gcd_longlong of sage.rings.fast_arith.arith_llong object at ...>
2241+
<bound method arith_llong.gcd_longlong of <sage.rings.fast_arith.arith_llong object at ...>
22422242
sage: sage.arith.misc.get_gcd(4000000000)
22432243
<function gcd at ...>
22442244
"""
@@ -2258,9 +2258,9 @@ def get_inverse_mod(order):
22582258
EXAMPLES::
22592259
22602260
sage: sage.arith.misc.get_inverse_mod(6000)
2261-
<built-in method inverse_mod_int of sage.rings.fast_arith.arith_int object at ...>
2261+
<bound method arith_int.inverse_mod_int of <sage.rings.fast_arith.arith_int object at ...>
22622262
sage: sage.arith.misc.get_inverse_mod(600000)
2263-
<built-in method inverse_mod_longlong of sage.rings.fast_arith.arith_llong object at ...>
2263+
<bound method arith_llong.inverse_mod_longlong of <sage.rings.fast_arith.arith_llong object at ...>
22642264
sage: sage.arith.misc.get_inverse_mod(6000000000)
22652265
<function inverse_mod at ...>
22662266
"""

src/sage/categories/modules.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,8 @@ def base_ring(self):
769769
This ``base_ring`` method is actually overridden by
770770
:meth:`sage.structure.category_object.CategoryObject.base_ring`::
771771
772-
sage: H.base_ring.__module__ # needs sage.modules
772+
sage: H.base_ring.__module__
773+
'sage.structure.category_object'
773774
774775
Here we call it directly::
775776

src/sage/categories/primer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ class SubcategoryMethods:
931931
to use Sage's introspection tools to recover where it's implemented::
932932
933933
sage: x._repr_.__module__
934+
'sage.structure.element_wrapper'
934935
sage: sage.misc.sageinspect.sage_getfile(x._repr_)
935936
'.../sage/structure/element_wrapper.pyx'
936937

src/sage/combinat/sf/classical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def init():
4343
sage: sage.combinat.sf.classical.conversion_functions = {}
4444
sage: init()
4545
sage: sage.combinat.sf.classical.conversion_functions[('Schur', 'powersum')]
46-
<built-in function t_SCHUR_POWSYM_symmetrica>
46+
<cyfunction t_SCHUR_POWSYM_symmetrica at ...>
4747
4848
The following checks if the bug described in :issue:`15312` is fixed. ::
4949

src/sage/graphs/base/static_sparse_backend.pyx

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,42 +1509,6 @@ cdef class StaticSparseBackend(CGraphBackend):
15091509
yield self._vertex_to_labels[u]
15101510
seen.add(u)
15111511

1512-
def add_vertex(self, v):
1513-
r"""
1514-
Addition of vertices is not available on an immutable graph.
1515-
1516-
EXAMPLES::
1517-
1518-
sage: g = DiGraph(graphs.PetersenGraph(), data_structure='static_sparse')
1519-
sage: g.add_vertex(1)
1520-
Traceback (most recent call last):
1521-
...
1522-
TypeError: this graph is immutable and so cannot be changed
1523-
sage: g.add_vertices([1,2,3])
1524-
Traceback (most recent call last):
1525-
...
1526-
TypeError: this graph is immutable and so cannot be changed
1527-
"""
1528-
(<StaticSparseCGraph> self._cg).add_vertex(v)
1529-
1530-
def del_vertex(self, v):
1531-
r"""
1532-
Removal of vertices is not available on an immutable graph.
1533-
1534-
EXAMPLES::
1535-
1536-
sage: g = DiGraph(graphs.PetersenGraph(), data_structure='static_sparse')
1537-
sage: g.delete_vertex(1)
1538-
Traceback (most recent call last):
1539-
...
1540-
TypeError: this graph is immutable and so cannot be changed
1541-
sage: g.delete_vertices([1,2,3])
1542-
Traceback (most recent call last):
1543-
...
1544-
TypeError: this graph is immutable and so cannot be changed
1545-
"""
1546-
(<StaticSparseCGraph> self._cg).del_vertex(v)
1547-
15481512

15491513
@cython.binding(True)
15501514
def _run_it_on_static_instead(f):

src/sage/graphs/strongly_regular_db.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ def is_RSHCD(int v, int k, int l, int mu):
11611161

11621162
sage: from sage.graphs.strongly_regular_db import is_RSHCD
11631163
sage: t = is_RSHCD(64,27,10,12); t # needs sage.combinat sage.modules
1164-
[<built-in function SRG_from_RSHCD>, 64, 27, 10, 12]
1164+
[<cyfunction SRG_from_RSHCD at ...>, 64, 27, 10, 12]
11651165
sage: g = t[0](*t[1:]); g # needs sage.combinat sage.modules
11661166
Graph on 64 vertices
11671167
sage: g.is_strongly_regular(parameters=True) # needs sage.combinat sage.modules

src/sage/interfaces/axiom.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,36 +179,49 @@
179179
import os
180180
import re
181181

182-
import sage.interfaces.abc
182+
from pexpect import EOF
183183

184-
from .expect import Expect, ExpectElement, FunctionElement, ExpectFunction
184+
import sage.interfaces.abc
185185
from sage.env import DOT_SAGE
186-
from pexpect import EOF
187-
from sage.misc.multireplace import multiple_replace
186+
from sage.interfaces.expect import (
187+
Expect,
188+
ExpectElement,
189+
ExpectFunction,
190+
FunctionElement,
191+
)
188192
from sage.interfaces.tab_completion import ExtraTabCompletion
189193
from sage.misc.instancedoc import instancedoc
194+
from sage.misc.multireplace import multiple_replace
190195
from sage.structure.richcmp import rich_to_bool
191196

192-
193197
# The Axiom commands ")what thing det" ")show Matrix" and ")display
194198
# op det" commands, gives a list of all identifiers that begin in
195199
# a certain way. This could maybe be useful somehow... (?) Also
196200
# axiom has a lot a lot of ways for getting documentation from the
197201
# system -- this could also be useful.
198202

203+
199204
class PanAxiom(ExtraTabCompletion, Expect):
200205
"""
201206
Interface to a PanAxiom interpreter.
202207
"""
203-
def __init__(self, name='axiom', command='axiom -nox -noclef',
204-
script_subdirectory=None, logfile=None,
205-
server=None, server_tmpdir=None,
206-
init_code=[')lisp (si::readline-off)']):
208+
209+
def __init__(
210+
self,
211+
name="axiom",
212+
command="axiom -nox -noclef",
213+
script_subdirectory=None,
214+
logfile=None,
215+
server=None,
216+
server_tmpdir=None,
217+
init_code=[")lisp (si::readline-off)"],
218+
):
207219
"""
208220
Create an instance of the Axiom interpreter.
209221
210222
TESTS::
211223
224+
sage: from sage.interfaces.axiom import axiom
212225
sage: axiom == loads(dumps(axiom))
213226
True
214227
"""
@@ -829,8 +842,8 @@ def _sage_(self):
829842
return self._sage_domain()
830843

831844
if type == "Float":
832-
from sage.rings.real_mpfr import RealField
833845
from sage.rings.integer_ring import ZZ
846+
from sage.rings.real_mpfr import RealField
834847
prec = max(self.mantissa().length()._sage_(), 53)
835848
R = RealField(prec)
836849
x, e, b = self.unparsed_input_form().lstrip('float(').rstrip(')').split(',')

0 commit comments

Comments
 (0)