Skip to content

Commit 3f30e4d

Browse files
author
Matthias Koeppe
committed
sage.misc: Update # needs
1 parent 0217fbd commit 3f30e4d

14 files changed

+676
-613
lines changed

src/sage/misc/cachefunc.pyx

Lines changed: 200 additions & 190 deletions
Large diffs are not rendered by default.

src/sage/misc/functional.py

Lines changed: 343 additions & 312 deletions
Large diffs are not rendered by default.

src/sage/misc/inherit_comparison.pyx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ cdef class InheritComparisonMetaclass(type):
5151
5252
EXAMPLES::
5353
54-
sage: cython( # optional - sage.misc.cython
54+
sage: # needs sage.misc.cython
55+
sage: cython(
5556
....: '''
5657
....: from sage.misc.inherit_comparison cimport InheritComparisonMetaclass
5758
....:
@@ -71,11 +72,11 @@ cdef class InheritComparisonMetaclass(type):
7172
....: def __hash__(self):
7273
....: return 1
7374
....: ''')
74-
sage: a = Derived() # optional - sage.misc.cython
75-
sage: a == a # optional - sage.misc.cython
75+
sage: a = Derived()
76+
sage: a == a
7677
True
77-
sage: b = DerivedWithRichcmp() # optional - sage.misc.cython
78-
sage: b == b # optional - sage.misc.cython
78+
sage: b = DerivedWithRichcmp()
79+
sage: b == b
7980
Calling Base.__richcmp__
8081
True
8182
"""

src/sage/misc/latex_macros.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ def produce_latex_macro(name, *sample_args):
6666
definition. The following allows the use of "\GF{p^n}", for
6767
example::
6868
69-
sage: produce_latex_macro('GF', 37) # optional - sage.libs.pari
69+
sage: produce_latex_macro('GF', 37)
7070
'\\newcommand{\\GF}[1]{\\Bold{F}_{#1}}'
7171
7272
If the Sage object is not in the global name space, describe it
7373
like so::
7474
75-
sage: produce_latex_macro('sage.rings.finite_rings.finite_field_constructor.FiniteField', 3) # optional - sage.libs.pari
75+
sage: produce_latex_macro('sage.rings.finite_rings.finite_field_constructor.FiniteField', 3)
7676
'\\newcommand{\\FiniteField}[1]{\\Bold{F}_{#1}}'
7777
"""
7878
from sage.misc.latex import LatexCall # type: ignore

src/sage/misc/lazy_list.pyx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,24 +305,25 @@ def lazy_list_formatter(L, name='lazy list',
305305
306306
::
307307
308+
sage: # needs sage.libs.pari
308309
sage: from sage.misc.lazy_list import lazy_list
309-
sage: L = lazy_list(Primes()); L # needs sage.libs.pari
310+
sage: L = lazy_list(Primes()); L
310311
lazy list [2, 3, 5, ...]
311312
sage: repr(L) == lazy_list_formatter(L)
312313
True
313-
sage: lazy_list_formatter(L, name='primes') # needs sage.libs.pari
314+
sage: lazy_list_formatter(L, name='primes')
314315
'primes [2, 3, 5, ...]'
315-
sage: lazy_list_formatter(L, opening_delimiter='(', closing_delimiter=')') # needs sage.libs.pari
316+
sage: lazy_list_formatter(L, opening_delimiter='(', closing_delimiter=')')
316317
'lazy list (2, 3, 5, ...)'
317-
sage: lazy_list_formatter(L, opening_delimiter='', closing_delimiter='') # needs sage.libs.pari
318+
sage: lazy_list_formatter(L, opening_delimiter='', closing_delimiter='')
318319
'lazy list 2, 3, 5, ...'
319-
sage: lazy_list_formatter(L, separator='--') # needs sage.libs.pari
320+
sage: lazy_list_formatter(L, separator='--')
320321
'lazy list [2--3--5--...]'
321-
sage: lazy_list_formatter(L, more='and more') # needs sage.libs.pari
322+
sage: lazy_list_formatter(L, more='and more')
322323
'lazy list [2, 3, 5, and more]'
323-
sage: lazy_list_formatter(L, preview=10) # needs sage.libs.pari
324+
sage: lazy_list_formatter(L, preview=10)
324325
'lazy list [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, ...]'
325-
sage: lazy_list_formatter(L, name='primes', # needs sage.libs.pari
326+
sage: lazy_list_formatter(L, name='primes',
326327
....: opening_delimiter='', closing_delimiter='',
327328
....: separator=' ', more='->', preview=7)
328329
'primes 2 3 5 7 11 13 17 ->'

src/sage/misc/lazy_string.pyx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -519,24 +519,25 @@ cdef class _LazyString():
519519
520520
EXAMPLES::
521521
522+
sage: # needs sage.libs.pari
522523
sage: from sage.misc.lazy_string import lazy_string
523524
sage: def f(op, A, B):
524525
....: return "unsupported operand parent(s) for %s: '%s' and '%s'" % (op, A, B)
525-
sage: R = GF(5) # optional - sage.libs.pari
526-
sage: S = GF(3) # optional - sage.libs.pari
527-
sage: D = lazy_string(f, '+', R, S) # optional - sage.libs.pari
528-
sage: D # optional - sage.libs.pari
526+
sage: R = GF(5)
527+
sage: S = GF(3)
528+
sage: D = lazy_string(f, '+', R, S)
529+
sage: D
529530
l"unsupported operand parent(s) for +: 'Finite Field of size 5' and 'Finite Field of size 3'"
530-
sage: D.update_lazy_string(('+', S, R), {}) # optional - sage.libs.pari
531+
sage: D.update_lazy_string(('+', S, R), {})
531532
532533
Apparently, the lazy string got changed in-place::
533534
534-
sage: D # optional - sage.libs.pari
535+
sage: D # needs sage.libs.pari
535536
l"unsupported operand parent(s) for +: 'Finite Field of size 3' and 'Finite Field of size 5'"
536537
537538
TESTS::
538539
539-
sage: D.update_lazy_string(None, None)
540+
sage: D.update_lazy_string(None, None) # needs sage.libs.pari
540541
Traceback (most recent call last):
541542
...
542543
TypeError: Expected tuple, got NoneType

src/sage/misc/nested_class.pyx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,19 @@ cpdef modify_for_nested_pickle(cls, str name_prefix, module, first_run=True):
162162
....: " class B2:",
163163
....: " class C2: pass"]
164164
sage: import os
165-
sage: cython(os.linesep.join(cython_code)) # optional - sage.misc.cython
165+
sage: cython(os.linesep.join(cython_code)) # needs sage.misc.cython
166166
167167
Before :trac:`9107`, the name of ``A1.B1.C1`` would have been wrong::
168168
169-
sage: A1.B1.C1.__name__ # optional - sage.misc.cython
169+
sage: # needs sage.misc.cython
170+
sage: A1.B1.C1.__name__
170171
'A1.B1.C1'
171-
sage: A1.B2.C2.__name__ # optional - sage.misc.cython
172+
sage: A1.B2.C2.__name__
172173
'A1.B2.C2'
173-
sage: A_module = sys.modules[A1.__module__] # optional - sage.misc.cython
174-
sage: getattr(A_module, 'A1.B1.C1', 'Not found').__name__ # optional - sage.misc.cython
174+
sage: A_module = sys.modules[A1.__module__]
175+
sage: getattr(A_module, 'A1.B1.C1', 'Not found').__name__
175176
'A1.B1.C1'
176-
sage: getattr(A_module, 'A1.B2.C2', 'Not found').__name__ # optional - sage.misc.cython
177+
sage: getattr(A_module, 'A1.B2.C2', 'Not found').__name__
177178
'A1.B2.C2'
178179
179180
"""

src/sage/misc/package.py

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,19 @@ def pip_installed_packages(normalization=None):
176176
177177
EXAMPLES::
178178
179+
sage: # optional - sage_spkg
179180
sage: from sage.misc.package import pip_installed_packages
180-
sage: d = pip_installed_packages() # optional - sage_spkg
181-
sage: 'scipy' in d or 'SciPy' in d # optional - sage_spkg
181+
sage: d = pip_installed_packages()
182+
sage: 'scipy' in d or 'SciPy' in d
182183
True
183-
sage: d['beautifulsoup4'] # optional - sage_spkg beautifulsoup4
184+
sage: d['beautifulsoup4'] # optional - beautifulsoup4
184185
'...'
185-
sage: d['prompt-toolkit'] # optional - sage_spkg
186+
sage: d['prompt-toolkit']
186187
'...'
187-
sage: d = pip_installed_packages(normalization='spkg') # optional - sage_spkg
188-
sage: d['prompt_toolkit'] # optional - sage_spkg
188+
sage: d = pip_installed_packages(normalization='spkg')
189+
sage: d['prompt_toolkit']
189190
'...'
190-
sage: d['scipy'] # optional - sage_spkg
191+
sage: d['scipy']
191192
'...'
192193
"""
193194
with open(os.devnull, 'w') as devnull:
@@ -293,27 +294,29 @@ def list_packages(*pkg_types: str, pkg_sources: List[str] = ['normal', 'pip', 's
293294
294295
EXAMPLES::
295296
297+
sage: # optional - sage_spkg
296298
sage: from sage.misc.package import list_packages
297-
sage: L = list_packages('standard') # optional - sage_spkg
298-
sage: sorted(L.keys()) # optional - sage_spkg, random
299+
sage: L = list_packages('standard')
300+
sage: sorted(L.keys())
299301
['alabaster',
300302
'arb',
301303
'babel',
302304
...
303305
'zlib']
304-
sage: sage_conf_info = L['sage_conf'] # optional - sage_spkg
305-
sage: sage_conf_info.type # optional - sage_spkg
306+
sage: sage_conf_info = L['sage_conf']
307+
sage: sage_conf_info.type
306308
'standard'
307-
sage: sage_conf_info.is_installed() # optional - sage_spkg
309+
sage: sage_conf_info.is_installed()
308310
True
309-
sage: sage_conf_info.source # optional - sage_spkg
311+
sage: sage_conf_info.source
310312
'script'
311313
312-
sage: L = list_packages(pkg_sources=['pip'], local=True) # optional - sage_spkg internet
313-
sage: bp_info = L['biopython'] # optional - sage_spkg internet
314-
sage: bp_info.type # optional - sage_spkg internet
314+
sage: # optional - sage_spkg internet
315+
sage: L = list_packages(pkg_sources=['pip'], local=True)
316+
sage: bp_info = L['biopython']
317+
sage: bp_info.type
315318
'optional'
316-
sage: bp_info.source # optional - sage_spkg internet
319+
sage: bp_info.source
317320
'pip'
318321
319322
Check the option ``exclude_pip``::
@@ -424,10 +427,10 @@ def installed_packages(exclude_pip=True):
424427
records of Python packages. Our ``SAGE_VENV`` is not necessarily the
425428
main Sage venv; it could be a user-created venv or a venv created by tox.)::
426429
427-
sage: from sage.misc.package import installed_packages
428-
sage: sorted(installed_packages().keys()) # optional - sage_spkg
430+
sage: # optional - sage_spkg
431+
sage: sorted(installed_packages().keys())
429432
[...'conway_polynomials', ...]
430-
sage: installed_packages()['conway_polynomials'] # optional - sage_spkg, random
433+
sage: installed_packages()['conway_polynomials']
431434
'0.5'
432435
433436
.. SEEALSO::
@@ -534,11 +537,11 @@ def package_versions(package_type, local=False):
534537
535538
EXAMPLES::
536539
537-
sage: from sage.misc.package import package_versions
538-
sage: std = package_versions('standard', local=True) # optional - sage_spkg
539-
sage: 'gap' in std # optional - sage_spkg
540+
sage: # optional - sage_spkg
541+
sage: std = package_versions('standard', local=True)
542+
sage: 'gap' in std
540543
True
541-
sage: std['zlib'] # optional - sage_spkg, random
544+
sage: std['zlib']
542545
('1.2.11.p0', '1.2.11.p0')
543546
"""
544547
return {pkg.name: (pkg.installed_version, pkg.remote_version) for pkg in list_packages(package_type, local=local).values()}
@@ -597,12 +600,13 @@ def optional_packages():
597600
598601
EXAMPLES::
599602
603+
sage: # optional - sage_spkg
600604
sage: from sage.misc.package import optional_packages
601-
sage: installed, not_installed = optional_packages() # optional - sage_spkg
605+
sage: installed, not_installed = optional_packages()
602606
doctest:...: DeprecationWarning: ...
603-
sage: 'biopython' in installed + not_installed # optional - sage_spkg
607+
sage: 'biopython' in installed + not_installed
604608
True
605-
sage: 'biopython' in installed # optional - sage_spkg biopython
609+
sage: 'biopython' in installed # optional - biopython
606610
True
607611
"""
608612
from sage.misc.superseded import deprecation
@@ -661,11 +665,12 @@ def package_manifest(package):
661665
662666
EXAMPLES::
663667
668+
sage: # optional - sage_spkg
664669
sage: from sage.misc.package import package_manifest
665-
sage: manifest = package_manifest('conway_polynomials') # optional - sage_spkg
666-
sage: manifest['package_name'] == 'conway_polynomials' # optional - sage_spkg
670+
sage: manifest = package_manifest('conway_polynomials')
671+
sage: manifest['package_name'] == 'conway_polynomials'
667672
True
668-
sage: 'files' in manifest # optional - sage_spkg
673+
sage: 'files' in manifest
669674
True
670675
671676
Test a nonexistent package::

src/sage/misc/repr.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ def coeff_repr(c, is_latex=False):
2020
sage: from sage.misc.repr import coeff_repr
2121
sage: coeff_repr(QQ(1/2))
2222
'1/2'
23-
sage: coeff_repr(-x^2) # optional - sage.symbolic
23+
sage: coeff_repr(-x^2) # needs sage.symbolic
2424
'(-x^2)'
2525
sage: coeff_repr(QQ(1/2), is_latex=True)
2626
'\\frac{1}{2}'
27-
sage: coeff_repr(-x^2, is_latex=True) # optional - sage.symbolic
27+
sage: coeff_repr(-x^2, is_latex=True) # needs sage.symbolic
2828
'\\left(-x^{2}\\right)'
2929
"""
3030
if not is_latex:
@@ -131,12 +131,13 @@ def repr_lincomb(terms, is_latex=False, scalar_mult="*", strip_one=False,
131131
132132
Verify that :trac:`31672` is fixed::
133133
134-
sage: alpha = var("alpha") # optional - sage.symbolic
135-
sage: repr_lincomb([(x, alpha)], is_latex=True) # optional - sage.symbolic
134+
sage: # needs sage.symbolic
135+
sage: alpha = var("alpha")
136+
sage: repr_lincomb([(x, alpha)], is_latex=True)
136137
'\\alpha x'
137-
sage: A.<psi> = PolynomialRing(QQ) # optional - sage.symbolic
138-
sage: B.<t> = FreeAlgebra(A) # optional - sage.combinat sage.modules sage.symbolic
139-
sage: (psi * t)._latex_() # optional - sage.combinat sage.modules sage.symbolic
138+
sage: A.<psi> = PolynomialRing(QQ)
139+
sage: B.<t> = FreeAlgebra(A) # needs sage.combinat sage.modules
140+
sage: (psi * t)._latex_() # needs sage.combinat sage.modules
140141
'\\psi t'
141142
"""
142143
# Setting scalar_mult: symbol used for scalar multiplication

src/sage/misc/sage_input.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,16 @@ def sage_input(x, preparse=True, verify=False, allow_locals=False):
229229
The result of :func:`sage_input` is actually a pair of strings with a
230230
special ``__repr__`` method to print nicely.::
231231
232-
sage: r = sage_input(RealField(20)(pi), verify=True) # needs sage.symbolic
233-
sage: r # needs sage.symbolic
232+
sage: # needs sage.rings.real_mpfr sage.symbolic
233+
sage: r = sage_input(RealField(20)(pi), verify=True)
234+
sage: r
234235
# Verified
235236
RealField(20)(3.1415939)
236-
sage: isinstance(r, tuple) # needs sage.symbolic
237+
sage: isinstance(r, tuple)
237238
True
238-
sage: len(r) # needs sage.symbolic
239+
sage: len(r)
239240
2
240-
sage: tuple(r) # needs sage.symbolic
241+
sage: tuple(r)
241242
('# Verified\n', 'RealField(20)(3.1415939)')
242243
243244
We cannot find an input form for a function.::
@@ -406,7 +407,7 @@ def __call__(self, x, coerced=False):
406407
sage: sage_input(float(-pi), preparse=True, verify=True) # needs sage.symbolic
407408
# Verified
408409
float(-RR(3.1415926535897931))
409-
sage: sage_input(float(42), preparse=True, verify=True)
410+
sage: sage_input(float(42), preparse=True, verify=True) # needs sage.rings.real_mpfr
410411
# Verified
411412
float(42)
412413
sage: sage_input("Hello, world\n", verify=True)
@@ -427,7 +428,7 @@ def __call__(self, x, coerced=False):
427428
sage: sage_input('unicode with spectral: \u1234\U00012345', verify=True)
428429
# Verified
429430
'unicode with spectral: \u1234\U00012345'
430-
sage: sage_input((2, 3.5, 'Hi'), verify=True)
431+
sage: sage_input((2, 3.5, 'Hi'), verify=True) # needs sage.rings.real_mpfr
431432
# Verified
432433
(2, 3.5, 'Hi')
433434
sage: sage_input(lambda x: x)

0 commit comments

Comments
 (0)