Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage.rings: Reformat doctests, add # optional annotations #35457

Merged
merged 52 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
dae9b08
sage.rings: Add # optional
mkoeppe Apr 8, 2023
4d20f8a
sage.rings: Reformat doctests and # optional
mkoeppe Apr 8, 2023
2e8a3bb
sage.rings: More # optional
mkoeppe Apr 8, 2023
2d4a62b
sage.rings: Reformat doctests and # optional
mkoeppe Apr 8, 2023
1c15000
src/sage/misc/cachefunc.pyx: Update doctest output
mkoeppe Feb 22, 2023
c1721ab
src/sage/rings/multi_power_series_ring_element.py: Fix up
mkoeppe Apr 8, 2023
a0e7176
sage.rings: Align # optional
mkoeppe Apr 8, 2023
f00b281
sage.rings: Doctest cosmetics
mkoeppe Apr 8, 2023
ab389e2
sage.rings: More doctest cosmetics
mkoeppe Apr 9, 2023
1a09248
src/sage/rings/integer.pyx: Fix up
mkoeppe Apr 9, 2023
64d094c
src/sage/rings/polynomial/multi_polynomial_sequence.py: Doctest cosme…
mkoeppe Apr 9, 2023
0148f5c
src/sage/rings/polynomial/multi_polynomial_sequence.py: Fix up
mkoeppe Apr 9, 2023
d7b15d2
sage.rings: More doctest cosmetics
mkoeppe Apr 9, 2023
d8bd93c
src/sage/sets/set_from_iterator.py: Fix up doctest
mkoeppe Apr 9, 2023
92f759b
Merge tag '10.0.beta9' into sage_rings_optional_annotations
mkoeppe Apr 14, 2023
bf431b4
src/sage/rings/factorint.pyx: Revert; this file is handled in #35502
mkoeppe Apr 14, 2023
7c692b9
sage.rings: Docstring/doctest cosmetics
mkoeppe Apr 15, 2023
7260301
src/sage/misc/sageinspect.py: Update doctest output
mkoeppe Apr 15, 2023
9f22bf8
sage.rings.polynomial: Docstring cosmetics
mkoeppe Apr 16, 2023
27884d3
sage.rings.polynomial: Fix docstring markup
mkoeppe Apr 16, 2023
9f1d9e8
src/sage/rings/polynomial/polynomial_zz_pex.pyx: Fix typo
mkoeppe Apr 17, 2023
d2546a6
src/doc/en/reference/rings/index.rst: Add sage.rings.abc
mkoeppe Apr 19, 2023
9ece1bd
sage.rings: Fix docstring markup, # optional
mkoeppe Apr 19, 2023
7e95b66
sage.rings: Fix some # optional
mkoeppe Apr 19, 2023
f5c7df6
src/sage/rings/polynomial/symmetric_ideal.py: Fix some # optional
mkoeppe Apr 19, 2023
1e649be
sage.rings: Fix some # optional
mkoeppe Apr 20, 2023
7be1a73
src/sage/rings/laurent_series_ring.py: Add # optional - sage.symbolic
mkoeppe Apr 20, 2023
bc4abf6
src/sage/rings/polynomial/symmetric_ideal.py: Docstring cosmetics
mkoeppe Apr 20, 2023
c4eed97
src/sage/rings/integer.pyx: Docstring markup fix
mkoeppe Apr 20, 2023
5889ded
git grep -l -E 'Returns? [Tt]rue' src/sage/rings | xargs sed -i.bak -…
mkoeppe Apr 20, 2023
f9c3508
src/sage/rings/fraction_field_FpT.pyx: Docstring cosmetics
mkoeppe Apr 20, 2023
50d6426
src/sage/rings/number_field/number_field.py: Docstring cosmetics
mkoeppe Apr 20, 2023
b0822d3
src/sage/rings/number_field: Docstring cosmetics
mkoeppe Apr 20, 2023
a13254b
src/sage/rings/number_field/number_field_ideal.py: Docstring cosmetics
mkoeppe Apr 21, 2023
1f20e69
src/sage/rings/number_field/number_field[_ideal]_rel.py: Docstring co…
mkoeppe Apr 21, 2023
0718614
src/sage/rings/number_field/order.py: Docstring cosmetics
mkoeppe Apr 21, 2023
22f7c56
src/sage/rings/padics: Doctest cosmetics
mkoeppe Apr 21, 2023
32606c6
src/sage/rings/padics: Fix up markup
mkoeppe Apr 21, 2023
0693bd6
src/sage/rings/number_field/number_field.py: Fix markup, doctest
mkoeppe Apr 21, 2023
ffd8c23
src/sage/rings/padics: Fix up markup
mkoeppe Apr 21, 2023
bf1b53d
src/sage/rings/number_field: Docstring cosmetics
mkoeppe Apr 22, 2023
8b427ec
src/sage/rings/padics: Docstring cosmetics
mkoeppe Apr 22, 2023
791a774
sage.rings: Docstring cosmetics, add # optional - sage.symbolic
mkoeppe Apr 22, 2023
2b9ffee
sage.rings: Add more # optional - sage.symbolic
mkoeppe Apr 22, 2023
8f26789
sage.rings: Add more # optional - sage.symbolic
mkoeppe Apr 22, 2023
fd1d43b
Merge tag '10.0.rc0' into sage_rings_optional_annotations
mkoeppe Apr 23, 2023
8c9808b
src/sage/rings/polynomial/multi_polynomial_sequence.py: Add # optional
mkoeppe Apr 24, 2023
ed969da
src/sage/misc/latex_macros.py: Add \lcm
mkoeppe May 14, 2023
a4aac37
Merge remote-tracking branch 'upstream/develop' into sage_rings_optio…
mkoeppe May 14, 2023
96701e5
Merge remote-tracking branch 'upstream/develop' into sage_rings_optio…
mkoeppe May 21, 2023
507b919
src/sage/rings/padics: Fix doc markup
mkoeppe May 21, 2023
1fa90d0
src/sage/misc/latex.py: Update doctest output
mkoeppe May 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/doc/en/reference/rings/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Base Classes for Rings, Algebras and Fields
:maxdepth: 1

sage/rings/ring
sage/rings/abc

Ideals
------
Expand Down
1 change: 1 addition & 0 deletions src/sage/misc/cachefunc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ cdef class CachedFunction():
sage: I = P*[x,y]
sage: from sage.misc.sageinspect import sage_getdoc
sage: print(sage_getdoc(I.groebner_basis)) # indirect doctest
WARNING: the enclosing module is marked...
Return the reduced Groebner basis of this ideal.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the warning message. Does it show in the doctesting?

...

Expand Down
1 change: 1 addition & 0 deletions src/sage/misc/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ def latex_extra_preamble():
\newcommand{\RLF}{\Bold{R}}
\newcommand{\SL}{\mathrm{SL}}
\newcommand{\PSL}{\mathrm{PSL}}
\newcommand{\lcm}{\mathop{\operatorname{lcm}}}
\newcommand{\Bold}[1]{\mathbf{#1}}
<BLANKLINE>
"""
Expand Down
3 changes: 2 additions & 1 deletion src/sage/misc/latex_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def convert_latex_macro_to_mathjax(macro):

# Use this list to define additional latex macros for sage documentation
latex_macros = [r"\newcommand{\SL}{\mathrm{SL}}",
r"\newcommand{\PSL}{\mathrm{PSL}}"]
r"\newcommand{\PSL}{\mathrm{PSL}}",
r"\newcommand{\lcm}{\mathop{\operatorname{lcm}}}"]

# The following is to allow customization of typesetting of rings:
# mathbf vs mathbb. See latex.py for more information.
Expand Down
8 changes: 4 additions & 4 deletions src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,8 +1920,8 @@ def _sage_getdoc_unformatted(obj):
Integer(x=None, base=0)
File: sage/rings/integer.pyx (starting at line ...)
<BLANKLINE>
The ``Integer`` class represents arbitrary precision
integers. It derives from the ``Element`` class, so
The :class:`Integer` class represents arbitrary precision
integers. It derives from the :class:`Element` class, so
integers can be used as ring elements anywhere in Sage.
...

Expand Down Expand Up @@ -1995,8 +1995,8 @@ def sage_getdoc_original(obj):

sage: print(sage_getdoc_original(sage.rings.integer.Integer))
<BLANKLINE>
The ``Integer`` class represents arbitrary precision
integers. It derives from the ``Element`` class, so
The :class:`Integer` class represents arbitrary precision
integers. It derives from the :class:`Element` class, so
integers can be used as ring elements anywhere in Sage.
...

Expand Down
58 changes: 29 additions & 29 deletions src/sage/rings/abc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class NumberField_quadratic(Field):
EXAMPLES::

sage: import sage.rings.abc
sage: K.<sqrt2> = QuadraticField(2) # optional - sage.rings.number_field
sage: isinstance(K, sage.rings.abc.NumberField_quadratic) # optional - sage.rings.number_field
sage: K.<sqrt2> = QuadraticField(2) # optional - sage.rings.number_field
sage: isinstance(K, sage.rings.abc.NumberField_quadratic) # optional - sage.rings.number_field
True
mkoeppe marked this conversation as resolved.
Show resolved Hide resolved

By design, there is a unique direct subclass::

sage: sage.rings.abc.NumberField_quadratic.__subclasses__() # optional - sage.rings.number_field
sage: sage.rings.abc.NumberField_quadratic.__subclasses__() # optional - sage.rings.number_field
[<class 'sage.rings.number_field.number_field.NumberField_quadratic'>]

sage: len(sage.rings.abc.NumberField_quadratic.__subclasses__()) <= 1
Expand All @@ -40,13 +40,13 @@ class NumberField_cyclotomic(Field):
EXAMPLES::

sage: import sage.rings.abc
sage: K.<zeta> = CyclotomicField(15) # optional - sage.rings.number_field
sage: isinstance(K, sage.rings.abc.NumberField_cyclotomic) # optional - sage.rings.number_field
sage: K.<zeta> = CyclotomicField(15) # optional - sage.rings.number_field
sage: isinstance(K, sage.rings.abc.NumberField_cyclotomic) # optional - sage.rings.number_field
True

By design, there is a unique direct subclass::

sage: sage.rings.abc.NumberField_cyclotomic.__subclasses__() # optional - sage.rings.number_field
sage: sage.rings.abc.NumberField_cyclotomic.__subclasses__() # optional - sage.rings.number_field
[<class 'sage.rings.number_field.number_field.NumberField_cyclotomic'>]

sage: len(sage.rings.abc.NumberField_cyclotomic.__subclasses__()) <= 1
Expand All @@ -66,16 +66,16 @@ class AlgebraicField_common(Field):
EXAMPLES::

sage: import sage.rings.abc
sage: isinstance(QQbar, sage.rings.abc.AlgebraicField_common) # optional - sage.rings.number_field
sage: isinstance(QQbar, sage.rings.abc.AlgebraicField_common) # optional - sage.rings.number_field
True
sage: isinstance(AA, sage.rings.abc.AlgebraicField_common) # optional - sage.rings.number_field
sage: isinstance(AA, sage.rings.abc.AlgebraicField_common) # optional - sage.rings.number_field
True

By design, other than the abstract subclasses :class:`~sage.rings.abc.AlgebraicField`
and :class:`~sage.rings.abc.AlgebraicRealField`, there is only one direct implementation
subclass::

sage: sage.rings.abc.AlgebraicField_common.__subclasses__() # optional - sage.rings.number_field
sage: sage.rings.abc.AlgebraicField_common.__subclasses__() # optional - sage.rings.number_field
[<class 'sage.rings.abc.AlgebraicField'>,
<class 'sage.rings.abc.AlgebraicRealField'>,
<class 'sage.rings.qqbar.AlgebraicField_common'>]
Expand All @@ -97,14 +97,14 @@ class AlgebraicField(AlgebraicField_common):
EXAMPLES::

sage: import sage.rings.abc
sage: isinstance(QQbar, sage.rings.abc.AlgebraicField) # optional - sage.rings.number_field
sage: isinstance(QQbar, sage.rings.abc.AlgebraicField) # optional - sage.rings.number_field
True
sage: isinstance(AA, sage.rings.abc.AlgebraicField) # optional - sage.rings.number_field
sage: isinstance(AA, sage.rings.abc.AlgebraicField) # optional - sage.rings.number_field
False

By design, there is a unique direct subclass::

sage: sage.rings.abc.AlgebraicField.__subclasses__() # optional - sage.rings.number_field
sage: sage.rings.abc.AlgebraicField.__subclasses__() # optional - sage.rings.number_field
[<class 'sage.rings.qqbar.AlgebraicField'>]

sage: len(sage.rings.abc.AlgebraicField.__subclasses__()) <= 1
Expand All @@ -124,14 +124,14 @@ class AlgebraicRealField(AlgebraicField_common):
EXAMPLES::

sage: import sage.rings.abc
sage: isinstance(QQbar, sage.rings.abc.AlgebraicRealField) # optional - sage.rings.number_field
sage: isinstance(QQbar, sage.rings.abc.AlgebraicRealField) # optional - sage.rings.number_field
False
sage: isinstance(AA, sage.rings.abc.AlgebraicRealField) # optional - sage.rings.number_field
sage: isinstance(AA, sage.rings.abc.AlgebraicRealField) # optional - sage.rings.number_field
True

By design, there is a unique direct subclass::

sage: sage.rings.abc.AlgebraicRealField.__subclasses__() # optional - sage.rings.number_field
sage: sage.rings.abc.AlgebraicRealField.__subclasses__() # optional - sage.rings.number_field
[<class 'sage.rings.qqbar.AlgebraicRealField'>]

sage: len(sage.rings.abc.AlgebraicRealField.__subclasses__()) <= 1
Expand Down Expand Up @@ -376,13 +376,13 @@ class Order:
EXAMPLES::

sage: import sage.rings.abc
sage: K.<a> = NumberField(x^2 + 1); O = K.order(2*a) # optional - sage.rings.number_field
sage: isinstance(O, sage.rings.abc.Order) # optional - sage.rings.number_field
sage: K.<a> = NumberField(x^2 + 1); O = K.order(2*a) # optional - sage.rings.number_field
sage: isinstance(O, sage.rings.abc.Order) # optional - sage.rings.number_field
True

By design, there is a unique direct subclass::

sage: sage.rings.abc.Order.__subclasses__() # optional - sage.rings.number_field
sage: sage.rings.abc.Order.__subclasses__() # optional - sage.rings.number_field
[<class 'sage.rings.number_field.order.Order'>]

sage: len(sage.rings.abc.Order.__subclasses__()) <= 1
Expand All @@ -402,14 +402,14 @@ class pAdicRing(EuclideanDomain):
EXAMPLES::

sage: import sage.rings.abc
sage: isinstance(Zp(5), sage.rings.abc.pAdicRing)
sage: isinstance(Zp(5), sage.rings.abc.pAdicRing) # optional - sage.rings.padics
True
sage: isinstance(Qp(5), sage.rings.abc.pAdicRing)
sage: isinstance(Qp(5), sage.rings.abc.pAdicRing) # optional - sage.rings.padics
False

By design, there is a unique direct subclass::

sage: sage.rings.abc.pAdicRing.__subclasses__()
sage: sage.rings.abc.pAdicRing.__subclasses__() # optional - sage.rings.padics
[<class 'sage.rings.padics.generic_nodes.pAdicRingGeneric'>]

sage: len(sage.rings.abc.pAdicRing.__subclasses__()) <= 1
Expand All @@ -429,14 +429,14 @@ class pAdicField(Field):
EXAMPLES::

sage: import sage.rings.abc
sage: isinstance(Zp(5), sage.rings.abc.pAdicField)
sage: isinstance(Zp(5), sage.rings.abc.pAdicField) # optional - sage.rings.padics
False
sage: isinstance(Qp(5), sage.rings.abc.pAdicField)
sage: isinstance(Qp(5), sage.rings.abc.pAdicField) # optional - sage.rings.padics
True

By design, there is a unique direct subclass::

sage: sage.rings.abc.pAdicField.__subclasses__()
sage: sage.rings.abc.pAdicField.__subclasses__() # optional - sage.rings.padics
[<class 'sage.rings.padics.generic_nodes.pAdicFieldGeneric'>]

sage: len(sage.rings.abc.pAdicField.__subclasses__()) <= 1
Expand All @@ -456,13 +456,13 @@ cdef class SymbolicRing(CommutativeRing):
EXAMPLES::

sage: import sage.rings.abc
sage: isinstance(SR, sage.rings.abc.SymbolicRing) # optional - sage.symbolic
sage: isinstance(SR, sage.rings.abc.SymbolicRing) # optional - sage.symbolic
True

By design, other than the abstract subclass :class:`~sage.rings.abc.CallableSymbolicExpressionRing`,
there is only one direct implementation subclass::

sage: sage.rings.abc.SymbolicRing.__subclasses__() # optional - sage.symbolic
sage: sage.rings.abc.SymbolicRing.__subclasses__() # optional - sage.symbolic
[<class 'sage.rings.abc.CallableSymbolicExpressionRing'>,
<class 'sage.symbolic.ring.SymbolicRing'>]

Expand All @@ -483,13 +483,13 @@ class CallableSymbolicExpressionRing(SymbolicRing):
EXAMPLES::

sage: import sage.rings.abc
sage: f = x.function(x).parent() # optional - sage.symbolic
sage: isinstance(f, sage.rings.abc.CallableSymbolicExpressionRing) # optional - sage.symbolic
sage: f = x.function(x).parent() # optional - sage.symbolic
sage: isinstance(f, sage.rings.abc.CallableSymbolicExpressionRing) # optional - sage.symbolic
True

By design, there is a unique direct subclass::

sage: sage.rings.abc.CallableSymbolicExpressionRing.__subclasses__() # optional - sage.symbolic
sage: sage.rings.abc.CallableSymbolicExpressionRing.__subclasses__() # optional - sage.symbolic
[<class 'sage.symbolic.callable.CallableSymbolicExpressionRing_class'>]

sage: len(sage.rings.abc.CallableSymbolicExpressionRing.__subclasses__()) <= 1
Expand Down
1 change: 1 addition & 0 deletions src/sage/rings/algebraic_closure_finite_field.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# sage.doctest: optional - sage.rings.finite_rings
r"""
Algebraic closures of finite fields

Expand Down
22 changes: 11 additions & 11 deletions src/sage/rings/bernmm.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Cython wrapper for bernmm library

AUTHOR:

- David Harvey (2008-06): initial version
- David Harvey (2008-06): initial version
"""

#*****************************************************************************
Expand Down Expand Up @@ -42,18 +42,18 @@ from sage.rings.rational cimport Rational

def bernmm_bern_rat(long k, int num_threads = 1):
r"""
Computes k-th Bernoulli number using a multimodular algorithm.
Compute `k`-th Bernoulli number using a multimodular algorithm.
(Wrapper for bernmm library.)

INPUT:

- k -- non-negative integer
- num_threads -- integer >= 1, number of threads to use
- ``k`` -- non-negative integer
- ``num_threads`` -- integer `\geq 1`, number of threads to use

COMPLEXITY:

Pretty much quadratic in `k`. See the paper "A multimodular algorithm
for computing Bernoulli numbers", David Harvey, 2008, for more details.
Pretty much quadratic in `k`. See the paper "A multimodular algorithm
for computing Bernoulli numbers", David Harvey, 2008, for more details.

EXAMPLES::

Expand Down Expand Up @@ -98,18 +98,18 @@ def bernmm_bern_rat(long k, int num_threads = 1):

def bernmm_bern_modp(long p, long k):
r"""
Computes `B_k \mod p`, where `B_k` is the k-th Bernoulli number.
Compute `B_k \mod p`, where `B_k` is the `k`-th Bernoulli number.

If `B_k` is not `p`-integral, returns -1.
If `B_k` is not `p`-integral, return `-1`.

INPUT:

p -- a prime
k -- non-negative integer
- ``p`` -- a prime
- ``k`` -- non-negative integer

COMPLEXITY:

Pretty much linear in `p`.
Pretty much linear in `p`.

EXAMPLES::

Expand Down
22 changes: 10 additions & 12 deletions src/sage/rings/bernoulli_mod_p.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ def verify_bernoulli_mod_p(data):

INPUT:

data -- list, same format as output of bernoulli_mod_p function
- ``data`` -- list, same format as output of :func:`bernoulli_mod_p` function

OUTPUT:

bool -- True if checksum passed
OUTPUT: bool -- True if checksum passed

EXAMPLES::

Expand Down Expand Up @@ -102,7 +100,7 @@ def bernoulli_mod_p(int p):

INPUT:

p -- integer, a prime
- ``p`` -- integer, a prime

OUTPUT:

Expand Down Expand Up @@ -134,7 +132,7 @@ def bernoulli_mod_p(int p):

AUTHOR:

-- David Harvey (2006-08-06)
- David Harvey (2006-08-06)

"""

Expand Down Expand Up @@ -233,12 +231,12 @@ def bernoulli_mod_p_single(long p, long k):
r"""
Return the Bernoulli number `B_k` mod `p`.

If `B_k` is not `p`-integral, an ArithmeticError is raised.
If `B_k` is not `p`-integral, an :class:`ArithmeticError` is raised.

INPUT:

- p -- integer, a prime
- k -- non-negative integer
- ``p`` -- integer, a prime
- ``k`` -- non-negative integer

OUTPUT:

Expand Down Expand Up @@ -274,7 +272,7 @@ def bernoulli_mod_p_single(long p, long k):
...
ValueError: k must be non-negative

Check results against bernoulli_mod_p::
Check results against :class:`bernoulli_mod_p`::

sage: bernoulli_mod_p(37)
[1, 31, 16, 15, 16, 4, 17, 32, 22, 31, 15, 15, 17, 12, 29, 2, 0, 2]
Expand Down Expand Up @@ -303,8 +301,8 @@ def bernoulli_mod_p_single(long p, long k):

AUTHOR:

-- David Harvey (2007-08-31)
-- David Harvey (2008-06): rewrote to use bernmm library
- David Harvey (2007-08-31)
- David Harvey (2008-06): rewrote to use bernmm library

"""
if p <= 2:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/cfinite_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ def an_element(self):

def __contains__(self, x):
"""
Return True if x is an element of ``CFiniteSequences`` or
Return ``True`` if x is an element of ``CFiniteSequences`` or
canonically coerces to this ring.

EXAMPLES::
Expand Down
Loading