Skip to content

Commit eaffa99

Browse files
author
Matthias Koeppe
committed
Fix placement of remaining '# optional - sage.misc.cython' tags
1 parent a6b3c65 commit eaffa99

File tree

15 files changed

+67
-46
lines changed

15 files changed

+67
-46
lines changed

src/sage/arith/long.pxd

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: optional - sage.misc.cython
12
r"""
23
Fast conversion of Python objects to C long
34
"""
@@ -113,7 +114,7 @@ cdef inline bint integer_check_long(x, long* value, int* err) except -1:
113114
114115
We create a pure Python wrapper of this function::
115116
116-
sage: cython(''' # optional - sage.misc.cython
117+
sage: cython('''
117118
....: from sage.arith.long cimport *
118119
....: from sage.rings.integer cimport smallInteger
119120
....: def check_long(x):
@@ -246,7 +247,7 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
246247
247248
We create a pure Python wrapper of this function::
248249
249-
sage: cython(''' # optional - sage.misc.cython
250+
sage: cython('''
250251
....: from sage.arith.long cimport *
251252
....: def check_long_py(x):
252253
....: cdef long value
@@ -371,7 +372,7 @@ cdef inline bint is_small_python_int(obj):
371372
372373
EXAMPLES::
373374
374-
sage: cython(''' # optional - sage.misc.cython
375+
sage: cython('''
375376
....: from sage.arith.long cimport is_small_python_int
376377
....: def is_small_wrapper(x):
377378
....: return is_small_python_int(x)

src/sage/cpython/cython_metaclass.pyx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ In Python, this would be ``meta.__init__(cls, name, bases, dict)``.
6161
6262
EXAMPLES::
6363
64-
sage: cython(''' # optional - sage.misc.cython
64+
sage: cython( # optional - sage.misc.cython
65+
....: '''
6566
....: cimport sage.cpython.cython_metaclass
6667
....: cdef class MyCustomType():
6768
....: def __getmetaclass__(_):
@@ -75,9 +76,9 @@ EXAMPLES::
7576
....: ''')
7677
Calling MyMetaclass.__init__(<class '...MyCustomType'>, None, None, None)
7778
Calling MyMetaclass.__init__(<class '...MyDerivedType'>, None, None, None)
78-
sage: MyCustomType.__class__
79+
sage: MyCustomType.__class__ # optional - sage.misc.cython
7980
<class '...MyMetaclass'>
80-
sage: class MyPythonType(MyDerivedType):
81+
sage: class MyPythonType(MyDerivedType): # optional - sage.misc.cython
8182
....: pass
8283
Calling MyMetaclass.__init__(<class '...MyPythonType'>, 'MyPythonType', (<class '...MyDerivedType'>,), {...})
8384
@@ -98,7 +99,8 @@ TESTS:
9899
Check that a proper exception is raised if ``__getmetaclass__``
99100
returns a non-type::
100101
101-
sage: cython(''' # optional - sage.misc.cython
102+
sage: cython( # optional - sage.misc.cython
103+
....: '''
102104
....: cimport sage.cpython.cython_metaclass
103105
....: cdef class MyCustomType():
104106
....: def __getmetaclass__(_):

src/sage/cpython/string.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ TESTS:
66
77
Check that this can be used outside of Sage (see :trac:`25549`)::
88
9-
sage: cython(''' # optional - sage.misc.cython
9+
sage: cython( # optional - sage.misc.cython
10+
....: '''
1011
....: from sage.cpython.string cimport char_to_str
1112
....: print(char_to_str("hello world!"))
1213
....: ''')

src/sage/cpython/wrapperdescr.pxd

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,25 @@ cdef inline wrapperbase* get_slotdef(wrapper_descriptor slotwrapper) except NULL
3939
4040
TESTS::
4141
42-
sage: cython(''' # optional - sage.misc.cython
42+
sage: cython( # optional - sage.misc.cython
43+
....: '''
4344
....: from sage.cpython.wrapperdescr cimport get_slotdef
4445
....: from cpython.long cimport PyLong_FromVoidPtr
4546
....: def py_get_slotdef(slotwrapper):
4647
....: return PyLong_FromVoidPtr(get_slotdef(slotwrapper))
4748
....: ''')
48-
sage: py_get_slotdef(object.__init__) # random
49+
sage: py_get_slotdef(object.__init__) # random # optional - sage.misc.cython
4950
140016903442416
50-
sage: py_get_slotdef(bytes.__lt__) # random
51+
sage: py_get_slotdef(bytes.__lt__) # random # optional - sage.misc.cython
5152
140016903441800
52-
sage: py_get_slotdef(bytes.__lt__) == py_get_slotdef(Integer.__lt__)
53+
sage: py_get_slotdef(bytes.__lt__) == py_get_slotdef(Integer.__lt__) # optional - sage.misc.cython
5354
True
54-
sage: py_get_slotdef(bytes.__lt__) == py_get_slotdef(bytes.__gt__)
55+
sage: py_get_slotdef(bytes.__lt__) == py_get_slotdef(bytes.__gt__) # optional - sage.misc.cython
5556
False
5657
sage: class X():
5758
....: def __eq__(self, other):
5859
....: return False
59-
sage: py_get_slotdef(X.__eq__)
60+
sage: py_get_slotdef(X.__eq__) # optional - sage.misc.cython
6061
Traceback (most recent call last):
6162
...
6263
TypeError: Cannot convert ... to wrapper_descriptor

src/sage/docs/instancedoc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
For a Cython ``cdef class``, a decorator cannot be used. Instead, call
3737
:func:`instancedoc` as a function after defining the class::
3838
39-
sage: cython(''' # optional - sage.misc.cython
39+
sage: cython( # optional - sage.misc.cython
40+
....: '''
4041
....: from sage.misc.instancedoc import instancedoc
4142
....: cdef class Y:
4243
....: "Class docstring"

src/sage/env.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ def cython_aliases(required_modules=None,
448448
We can use ``cython.parallel`` regardless of whether OpenMP is supported.
449449
This will run in parallel, if OpenMP is supported::
450450
451-
sage: cython(''' # optional - sage.misc.cython
451+
sage: cython( # optional - sage.misc.cython
452+
....: '''
452453
....: #distutils: extra_compile_args = OPENMP_CFLAGS
453454
....: #distutils: extra_link_args = OPENMP_CFLAGS
454455
....: from cython.parallel import prange

src/sage/ext/memory_allocator.pxd

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,17 @@ cdef class MemoryAllocator:
5656
5757
TESTS::
5858
59-
sage: cython(''' # optional - sage.misc.cython
59+
sage: cython( # optional - sage.misc.cython
60+
....: '''
6061
....: from sage.ext.memory_allocator cimport MemoryAllocator
6162
....: cdef MemoryAllocator mem = MemoryAllocator()
6263
....: cdef void* ptr
6364
....: for i in range(12):
6465
....: ptr = mem.aligned_malloc(2**i, 4048)
6566
....: assert <size_t> ptr == (<size_t> ptr) & ~(2**i-1)
6667
....: ''')
67-
doctest:...: DeprecationWarning: this class is deprecated; use the class from the python package `memory_allocator`
68+
doctest:...: DeprecationWarning: this class is deprecated;
69+
use the class from the python package `memory_allocator`
6870
See https://trac.sagemath.org/31591 for details.
6971
"""
7072
cdef size_t extra = alignment - 1
@@ -85,7 +87,8 @@ cdef class MemoryAllocator:
8587
8688
TESTS::
8789
88-
sage: cython(''' # optional - sage.misc.cython
90+
sage: cython( # optional - sage.misc.cython
91+
....: '''
8992
....: from sage.ext.memory_allocator cimport MemoryAllocator
9093
....: def foo():
9194
....: cdef MemoryAllocator mem = MemoryAllocator()
@@ -94,8 +97,9 @@ cdef class MemoryAllocator:
9497
....: ptr = mem.aligned_calloc(2**i, i, 2**i)
9598
....: assert <size_t> ptr == (<size_t> ptr) & ~(2**i-1)
9699
....: ''')
97-
sage: foo()
98-
doctest:...: DeprecationWarning: this class is deprecated; use the class from the python package `memory_allocator`
100+
sage: foo() # optional - sage.misc.cython
101+
doctest:...: DeprecationWarning: this class is deprecated;
102+
use the class from the python package `memory_allocator`
99103
See https://trac.sagemath.org/31591 for details.
100104
"""
101105
# Find extra such that (nmemb + extra) * size >= nmemb * size + alignment - 1
@@ -120,7 +124,8 @@ cdef class MemoryAllocator:
120124
121125
TESTS::
122126
123-
sage: cython(''' # optional - sage.misc.cython
127+
sage: cython( # optional - sage.misc.cython
128+
....: '''
124129
....: from sage.ext.memory_allocator cimport MemoryAllocator
125130
....: def foo():
126131
....: cdef MemoryAllocator mem = MemoryAllocator()
@@ -129,8 +134,8 @@ cdef class MemoryAllocator:
129134
....: ptr = mem.aligned_allocarray(2**i, i, 2**i)
130135
....: assert <size_t> ptr == (<size_t> ptr) & ~(2**i-1)
131136
....: ''')
132-
sage: foo() # random # might raise deprecation warning
133-
sage: foo()
137+
sage: foo() # random # might raise deprecation warning # optional - sage.misc.cython
138+
sage: foo() # optional - sage.misc.cython
134139
"""
135140
# Find extra such that (nmemb + extra) * size >= nmemb * size + alignment - 1
136141
# ⇔ extra * size >= alignment - 1

src/sage/misc/cython.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def cython(filename, verbose=0, compile_message=False,
171171
sage: os.chdir(d)
172172
sage: with open("helper.pxd", 'w') as f:
173173
....: _ = f.write("cdef inline int the_answer(): return 42")
174-
sage: cython(''' # optional - sage.misc.cython
174+
sage: cython('''
175175
....: from helper cimport the_answer
176176
....: print(the_answer())
177177
....: ''')
@@ -208,7 +208,7 @@ def cython(filename, verbose=0, compile_message=False,
208208
209209
As of :trac:`29139` the default is ``cdivision=True``::
210210
211-
sage: cython(''' # optional - sage.misc.cython
211+
sage: cython('''
212212
....: cdef size_t foo = 3/2
213213
....: ''')
214214
"""

src/sage/misc/sageinspect.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,13 +1372,14 @@ def sage_getfile(obj):
13721372
13731373
A problem fixed in :trac:`16309`::
13741374
1375-
sage: cython(''' # optional - sage.misc.cython
1375+
sage: cython( # optional - sage.misc.cython
1376+
....: '''
13761377
....: class Bar: pass
13771378
....: cdef class Foo: pass
13781379
....: ''')
1379-
sage: sage_getfile(Bar)
1380+
sage: sage_getfile(Bar) # optional - sage.misc.cython
13801381
'...pyx'
1381-
sage: sage_getfile(Foo)
1382+
sage: sage_getfile(Foo) # optional - sage.misc.cython
13821383
'...pyx'
13831384
13841385
By :trac:`18249`, we return an empty string for Python builtins. In that

src/sage/misc/superseded.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,17 @@ def deprecation_cython(trac_number, message, stacklevel=3):
108108
with the same callsite reference as `deprecation` in a python function, whereas
109109
`deprecation` in a cython function does not::
110110
111-
sage: cython(''' # optional - sage.misc.cython
111+
sage: cython( # optional - sage.misc.cython
112+
....: '''
112113
....: from sage.misc.superseded import deprecation_cython, deprecation
113114
....: def foo1():
114-
....: deprecation_cython(100,"boo")
115+
....: deprecation_cython(100, "boo")
115116
....: def foo2():
116-
....: deprecation(100,"boo")
117+
....: deprecation(100, "boo")
117118
....: ''')
118119
sage: def foo3():
119-
....: deprecation(100,"boo")
120-
sage: if True: # Execute the three "with" blocks as one doctest
120+
....: deprecation(100, "boo")
121+
sage: if True: # Execute the three "with" blocks as one doctest # optional - sage.misc.cython
121122
....: with warnings.catch_warnings(record=True) as w1:
122123
....: warnings.simplefilter("always")
123124
....: foo1()
@@ -127,9 +128,9 @@ def deprecation_cython(trac_number, message, stacklevel=3):
127128
....: with warnings.catch_warnings(record=True) as w3:
128129
....: warnings.simplefilter("always")
129130
....: foo3()
130-
sage: w1[0].filename == w3[0].filename
131+
sage: w1[0].filename == w3[0].filename # optional - sage.misc.cython
131132
True
132-
sage: w2[0].filename == w3[0].filename
133+
sage: w2[0].filename == w3[0].filename # optional - sage.misc.cython
133134
False
134135
"""
135136
warning(trac_number, message, DeprecationWarning, stacklevel)

0 commit comments

Comments
 (0)