Skip to content

Commit

Permalink
update doctests for cython 3
Browse files Browse the repository at this point in the history
  • Loading branch information
infmagic2047 committed Aug 20, 2023
1 parent a632238 commit 7195b8f
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/doc/en/thematic_tutorials/coercion_and_categories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ it makes sense to build on top of the base class
This base class provides a lot more methods than a general parent::

sage: [p for p in dir(Field) if p not in dir(Parent)]
['__fraction_field',
['_CommutativeRing__fraction_field',
'__iter__',
'__len__',
'__rxor__',
Expand Down
2 changes: 1 addition & 1 deletion src/sage/arith/srange.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def xsrange(start, end=None, step=1, universe=None, *, coerce=True, bint include
EXAMPLES::
sage: xsrange(10)
<generator object at 0x...>
<_cython_3_0_0.generator object at 0x...>
sage: for i in xsrange(1,5):
....: print(i)
1
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/sloane_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9171,7 +9171,7 @@ def __getattribute__(self, name):
::
sage: sloane.__repr__
<method-wrapper '__repr__' of Sloane object at 0x...>
<built-in method __repr__ of Sloane object at 0x...>
sage: sloane.__name__
Traceback (most recent call last):
...
Expand Down
7 changes: 4 additions & 3 deletions src/sage/misc/cachefunc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ be used::
sage: cython('''cpdef test_funct(x): return -x''') # optional - sage.misc.cython
sage: wrapped_funct = cached_function(test_funct, name='wrapped_funct') # optional - sage.misc.cython
sage: wrapped_funct # optional - sage.misc.cython
Cached version of <built-in function test_funct>
Cached version of <cyfunction test_funct at ...>
sage: wrapped_funct.__name__ # optional - sage.misc.cython
'wrapped_funct'
sage: wrapped_funct(5) # optional - sage.misc.cython
Expand Down Expand Up @@ -80,9 +80,9 @@ approach is still needed for cpdef methods::
sage: cython(os.linesep.join(cython_code)) # optional - sage.misc.cython
sage: O = MyClass() # optional - sage.misc.cython
sage: O.direct_method # optional - sage.misc.cython
Cached version of <method 'direct_method' of '...MyClass' objects>
Cached version of <cyfunction MyClass.direct_method at ...>
sage: O.wrapped_method # optional - sage.misc.cython
Cached version of <built-in function test_meth>
Cached version of <cyfunction test_meth at ...>
sage: O.wrapped_method.__name__ # optional - sage.misc.cython
'wrapped_method'
sage: O.wrapped_method(5) # optional - sage.misc.cython
Expand Down Expand Up @@ -263,6 +263,7 @@ Introspection works::
"some doc for a wrapped cython method"
return -x
sage: print(sage_getsource(O.direct_method)) # optional - sage.misc.cython
@cached_method
def direct_method(self, x):
"Some doc for direct method"
return 2*x
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/lazy_import.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ def lazy_import(module, names, as_=None, *,
sage: from sage.features import PythonModule
sage: lazy_import('ppl', 'equation', feature=PythonModule('ppl', spkg='pplpy', type='standard'))
sage: equation
<built-in function equation>
<cyfunction equation at ...>
sage: lazy_import('PyNormaliz', 'NmzListConeProperties', feature=PythonModule('PyNormaliz', spkg='pynormaliz')) # optional - pynormaliz
sage: NmzListConeProperties # optional - pynormaliz
<built-in function NmzListConeProperties>
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/lazy_list.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ cdef class lazy_list_generic():
sage: from itertools import count
sage: from sage.misc.lazy_list import lazy_list
sage: iter(lazy_list(count()))
<generator object at 0x...>
<_cython_3_0_0.generator object at 0x...>
::
Expand Down
4 changes: 2 additions & 2 deletions src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
sage: sage_getdoc(sage.rings.rational.make_rational).lstrip()
'Make a rational number ...'
sage: sage_getsource(sage.rings.rational.make_rational)[4:]
'make_rational(s):...'
sage: sage_getsource(sage.rings.rational.make_rational)
'@cython.binding(True)\ndef make_rational(s):...'
Python functions::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/free_module_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ cdef class FreeModuleElement(Vector): # abstract base class
sage: v = vector([1,2/3,pi])
sage: v.items()
<generator object at ...>
<_cython_3_0_0.generator object at ...>
sage: list(v.items())
[(0, 1), (1, 2/3), (2, pi)]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/finite_field_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ cdef class FiniteField(Field):
sage: p = next_prime(2^64)
sage: k.<a> = FiniteField(p^2, impl="pari")
sage: it = iter(k); it
<generator object at ...>
<_cython_3_0_0.generator object at ...>
sage: [next(it) for i in range(10)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/polynomial/skew_polynomial_finite_field.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
sage: S.<x> = k['x',Frob]
sage: a = x^4 + 2*t*x^3 + 3*t^2*x^2 + (t^2 + t + 1)*x + 4*t + 3
sage: iter = a.right_irreducible_divisors(); iter
<generator object at 0x...>
<_cython_3_0_0.generator object at 0x...>
sage: next(iter) # random
x + 2*t^2 + 4*t + 4
sage: next(iter) # random
Expand Down Expand Up @@ -664,7 +664,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
sage: S.<x> = k['x',Frob]
sage: a = x^4 + 2*t*x^3 + 3*t^2*x^2 + (t^2 + t + 1)*x + 4*t + 3
sage: iter = a.left_irreducible_divisors(); iter
<generator object at 0x...>
<_cython_3_0_0.generator object at 0x...>
sage: next(iter) # random
x + 3*t + 3
sage: next(iter) # random
Expand Down Expand Up @@ -1052,7 +1052,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
sage: S.<x> = k['x',Frob]
sage: a = x^3 + (t^2 + 1)*x^2 + (2*t + 3)*x + t^2 + t + 2
sage: iter = a.factorizations(); iter
<generator object at 0x...>
<_cython_3_0_0.generator object at 0x...>
sage: next(iter) # random
(x + 3*t^2 + 4*t) * (x + 2*t^2) * (x + 4*t^2 + 4*t + 2)
sage: next(iter) # random
Expand Down
4 changes: 2 additions & 2 deletions src/sage/structure/coerce_dict.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ cdef class MonoDict:
sage: L[1] = None
sage: L[2] = True
sage: L.items()
<generator object at ...>
<_cython_3_0_0.generator object at ...>
sage: sorted(L.items())
[(1, None), (2, True)]
"""
Expand Down Expand Up @@ -1451,7 +1451,7 @@ cdef class TripleDict:
sage: L = TripleDict()
sage: L[1,2,3] = None
sage: L.items()
<generator object at ...>
<_cython_3_0_0.generator object at ...>
sage: list(L.items())
[((1, 2, 3), None)]
"""
Expand Down
3 changes: 1 addition & 2 deletions src/sage/tests/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,8 @@ def test_executable(args, input="", timeout=100.0, pydebug_ignore_warnings=False
sage: (out, err, ret) = test_executable(["sage", "--cython"])
sage: print(err)
Cython (http://cython.org) is a compiler for code written in the
Cython language. Cython is based on Pyrex by Greg Ewing.
...
cython: error: cython: Need at least one source file
sage: def has_tty():
....: try:
Expand Down

0 comments on commit 7195b8f

Please sign in to comment.