Skip to content

Commit 0a7b251

Browse files
author
Release Manager
committed
gh-37790: Improve docstrings in groups
I parsed the `groups` module like a _robot_ and I edited the docstrings. (e.g. 1-line outputs, self to ``self``) ### ⌛ Dependencies Depends on #37789. URL: #37790 Reported by: gmou3 Reviewer(s): Matthias Köppe
2 parents a86a710 + 19f157e commit 0a7b251

File tree

77 files changed

+973
-1490
lines changed

Some content is hidden

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

77 files changed

+973
-1490
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=84471145bab92334f2220717f26487f2134ef8bb
3-
md5=306dee709dd7b945c378393b1e69d876
4-
cksum=2975864856
2+
sha1=f46d28f976fdd73aa93eff6810b28b3e7b165bf1
3+
md5=db30b8d7485d8c3b6f4f73a8282816be
4+
cksum=726460493
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
62f58efeda6b4ef3898bfd0c020b6ec3c6befd72
1+
3cffb4c1c8d29849cfeb9dc0332d7549800e044a

src/sage/groups/abelian_gps/abelian_aut.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ def matrix(self):
176176
The `i`-th row is the exponent vector of
177177
the image of the `i`-th generator.
178178
179-
OUTPUT:
180-
181-
- a square matrix over the integers
179+
OUTPUT: a square matrix over the integers
182180
183181
EXAMPLES::
184182
@@ -315,9 +313,7 @@ def _coerce_map_from_(self, S):
315313
316314
- ``S`` -- anything
317315
318-
OUTPUT:
319-
320-
Boolean or nothing
316+
OUTPUT: boolean or nothing
321317
322318
EXAMPLES::
323319

src/sage/groups/abelian_gps/abelian_group.py

Lines changed: 61 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@
4040
invariant factors of the group. You should now use
4141
:meth:`~AbelianGroup_class.gens_orders` instead::
4242
43-
sage: J = AbelianGroup([2,0,3,2,4]); J
44-
Multiplicative Abelian group isomorphic to C2 x Z x C3 x C2 x C4
45-
sage: J.gens_orders() # use this instead
46-
(2, 0, 3, 2, 4)
47-
sage: J.invariants() # deprecated
48-
(2, 0, 3, 2, 4)
49-
sage: J.elementary_divisors() # these are the "invariant factors"
50-
(2, 2, 12, 0)
51-
sage: for i in range(J.ngens()):
52-
....: print((i, J.gen(i), J.gen(i).order())) # or use this form
53-
(0, f0, 2)
54-
(1, f1, +Infinity)
55-
(2, f2, 3)
56-
(3, f3, 2)
57-
(4, f4, 4)
43+
sage: J = AbelianGroup([2,0,3,2,4]); J
44+
Multiplicative Abelian group isomorphic to C2 x Z x C3 x C2 x C4
45+
sage: J.gens_orders() # use this instead
46+
(2, 0, 3, 2, 4)
47+
sage: J.invariants() # deprecated
48+
(2, 0, 3, 2, 4)
49+
sage: J.elementary_divisors() # these are the "invariant factors"
50+
(2, 2, 12, 0)
51+
sage: for i in range(J.ngens()):
52+
....: print((i, J.gen(i), J.gen(i).order())) # or use this form
53+
(0, f0, 2)
54+
(1, f1, +Infinity)
55+
(2, f2, 3)
56+
(3, f3, 2)
57+
(4, f4, 4)
5858
5959
Background on invariant factors and the Smith normal form
6060
(according to section 4.1 of [Cohen1]_): An abelian group is a
@@ -160,7 +160,7 @@
160160
.. [Rotman] \J. Rotman, An introduction to the theory of
161161
groups, 4th ed, Springer, 1995.
162162
163-
.. warning::
163+
.. WARNING::
164164
165165
Many basic properties for infinite abelian groups are not
166166
implemented.
@@ -221,15 +221,17 @@
221221
from sage.structure.unique_representation import UniqueRepresentation
222222

223223

224-
# TODO: this uses perm groups - the AbelianGroupElement instance method
225-
# uses a different implementation.
224+
# .. TODO::
225+
226+
# this uses perm groups - the AbelianGroupElement instance method
227+
# uses a different implementation.
226228
def word_problem(words, g, verbose=False):
227229
r"""
228-
G and H are abelian, g in G, H is a subgroup of G generated by a
229-
list (words) of elements of G. If g is in H, return the expression
230-
for g as a word in the elements of (words).
230+
`G` and `H` are abelian, `g` in `G`, `H` is a subgroup of `G` generated by
231+
a list (words) of elements of `G`. If `g` is in `H`, return the expression
232+
for `g` as a word in the elements of (words).
231233
232-
The 'word problem' for a finite abelian group G boils down to the
234+
The 'word problem' for a finite abelian group `G` boils down to the
233235
following matrix-vector analog of the Chinese remainder theorem.
234236
235237
Problem: Fix integers `1<n_1\leq n_2\leq ...\leq n_k`
@@ -289,7 +291,7 @@ def word_problem(words, g, verbose=False):
289291
sage: word_problem([a,b,c,d,e], b)
290292
[[b, 1]]
291293
292-
.. warning::
294+
.. WARNING::
293295
294296
1. Might have unpleasant effect when the word problem
295297
cannot be solved.
@@ -448,7 +450,7 @@ def AbelianGroup(n, gens_orders=None, names="f"):
448450

449451
def is_AbelianGroup(x):
450452
"""
451-
Return True if ``x`` is an Abelian group.
453+
Return ``True`` if ``x`` is an Abelian group.
452454
453455
EXAMPLES::
454456
@@ -467,7 +469,7 @@ class AbelianGroup_class(UniqueRepresentation, AbelianGroupBase):
467469
"""
468470
The parent for Abelian groups with chosen generator orders.
469471
470-
.. warning::
472+
.. WARNING::
471473
472474
You should use :func:`AbelianGroup` to construct Abelian
473475
groups and not instantiate this class directly.
@@ -518,7 +520,7 @@ class AbelianGroup_class(UniqueRepresentation, AbelianGroupBase):
518520

519521
def __init__(self, generator_orders, names, category=None):
520522
"""
521-
The Python constructor
523+
The Python constructor.
522524
523525
TESTS::
524526
@@ -552,15 +554,13 @@ def __init__(self, generator_orders, names, category=None):
552554

553555
def is_isomorphic(left, right):
554556
"""
555-
Check whether ``left`` and ``right`` are isomorphic
557+
Check whether ``left`` and ``right`` are isomorphic.
556558
557559
INPUT:
558560
559561
- ``right`` -- anything.
560562
561-
OUTPUT:
562-
563-
Boolean. Whether ``left`` and ``right`` are isomorphic as abelian groups.
563+
OUTPUT: boolean; whether ``left`` and ``right`` are isomorphic as abelian groups
564564
565565
EXAMPLES::
566566
@@ -601,7 +601,7 @@ def is_subgroup(left, right):
601601

602602
def __ge__(left, right):
603603
"""
604-
Test whether ``right`` is a subgroup of ``left``
604+
Test whether ``right`` is a subgroup of ``left``.
605605
606606
EXAMPLES::
607607
@@ -614,7 +614,7 @@ def __ge__(left, right):
614614

615615
def __lt__(left, right):
616616
"""
617-
Test whether ``left`` is a strict subgroup of ``right``
617+
Test whether ``left`` is a strict subgroup of ``right``.
618618
619619
EXAMPLES::
620620
@@ -627,7 +627,7 @@ def __lt__(left, right):
627627

628628
def __gt__(left, right):
629629
"""
630-
Test whether ``right`` is a strict subgroup of ``left``
630+
Test whether ``right`` is a strict subgroup of ``left``.
631631
632632
EXAMPLES::
633633
@@ -640,7 +640,7 @@ def __gt__(left, right):
640640

641641
def is_trivial(self):
642642
"""
643-
Return whether the group is trivial
643+
Return whether the group is trivial.
644644
645645
A group is trivial if it has precisely one element.
646646
@@ -682,9 +682,7 @@ def dual_group(self, names="X", base_ring=None):
682682
- ``base_ring`` -- the base ring. If ``None`` (default), then
683683
a suitable cyclotomic field is picked automatically.
684684
685-
OUTPUT:
686-
687-
The :class:`dual abelian group <sage.groups.abelian_gps.dual_abelian_group.DualAbelianGroup_class>`.
685+
OUTPUT: the :class:`dual abelian group <sage.groups.abelian_gps.dual_abelian_group.DualAbelianGroup_class>`
688686
689687
EXAMPLES::
690688
@@ -719,9 +717,9 @@ def dual_group(self, names="X", base_ring=None):
719717
@cached_method
720718
def elementary_divisors(self):
721719
r"""
722-
This returns the elementary divisors of the group, using Pari.
720+
Return the elementary divisors of the group, using Pari.
723721
724-
.. note::
722+
.. NOTE::
725723
726724
Here is another algorithm for computing the elementary divisors
727725
`d_1, d_2, d_3, \ldots`, of a finite abelian group (where `d_1 | d_2 | d_3 | \ldots`
@@ -736,9 +734,7 @@ def elementary_divisors(self):
736734
on these "smaller invariants" to compute `d_{i-1}`, and so on.
737735
(Thanks to Robert Miller for communicating this algorithm.)
738736
739-
OUTPUT:
740-
741-
A tuple of integers.
737+
OUTPUT: tuple of integers
742738
743739
EXAMPLES::
744740
@@ -806,15 +802,13 @@ def identity(self):
806802

807803
def _group_notation(self, eldv):
808804
"""
809-
Return abstract group notation for generator orders ``eldv``
805+
Return abstract group notation for generator orders ``eldv``.
810806
811807
INPUT:
812808
813-
- ``eldv`` -- iterable of integers.
814-
815-
OUTPUT:
809+
- ``eldv`` -- iterable of integers
816810
817-
String.
811+
OUTPUT: string
818812
819813
EXAMPLES::
820814
@@ -955,9 +949,7 @@ def gens_orders(self):
955949
Use :meth:`elementary_divisors` if you are looking for an
956950
invariant of the group.
957951
958-
OUTPUT:
959-
960-
A tuple of integers.
952+
OUTPUT: tuple of integers
961953
962954
EXAMPLES::
963955
@@ -1018,9 +1010,7 @@ def invariants(self):
10181010
Use :meth:`elementary_divisors` if you are looking for an
10191011
invariant of the group.
10201012
1021-
OUTPUT:
1022-
1023-
A tuple of integers. Zero means infinite cyclic factor.
1013+
OUTPUT: tuple of integers; zero means infinite cyclic factor
10241014
10251015
EXAMPLES::
10261016
@@ -1043,7 +1033,7 @@ def invariants(self):
10431033

10441034
def is_cyclic(self):
10451035
"""
1046-
Return True if the group is a cyclic group.
1036+
Return ``True`` if the group is a cyclic group.
10471037
10481038
EXAMPLES::
10491039
@@ -1153,7 +1143,7 @@ def permutation_group(self):
11531143

11541144
def is_commutative(self):
11551145
"""
1156-
Return True since this group is commutative.
1146+
Return ``True`` since this group is commutative.
11571147
11581148
EXAMPLES::
11591149
@@ -1432,8 +1422,8 @@ def subgroups(self, check=False):
14321422
14331423
INPUT:
14341424
1435-
- check: if ``True``, performs the same computation in GAP and
1436-
checks that the number of subgroups generated is the
1425+
- ``check`` -- boolean; if ``True``, performs the same computation in
1426+
GAP and checks that the number of subgroups generated is the
14371427
same. (I don't know how to convert GAP's output back into
14381428
Sage, so we don't actually compare the subgroups).
14391429
@@ -1528,15 +1518,15 @@ def subgroups(self, check=False):
15281518

15291519
def subgroup_reduced(self, elts, verbose=False):
15301520
r"""
1531-
Given a list of lists of integers (corresponding to elements of self),
1532-
find a set of independent generators for the subgroup generated by
1533-
these elements, and return the subgroup with these as generators,
1534-
forgetting the original generators.
1521+
Given a list of lists of integers (corresponding to elements of
1522+
``self``), find a set of independent generators for the subgroup
1523+
generated by these elements, and return the subgroup with these as
1524+
generators, forgetting the original generators.
15351525
15361526
This is used by the ``subgroups`` routine.
15371527
15381528
An error will be raised if the elements given are not linearly
1539-
independent over QQ.
1529+
independent over `\QQ`.
15401530
15411531
EXAMPLES::
15421532
@@ -1595,7 +1585,8 @@ def torsion_subgroup(self, n=None):
15951585
15961586
sage: G = AbelianGroup([2, 2*3, 2*3*5, 0, 2*3*5*7, 2*3*5*7*11])
15971587
sage: G.torsion_subgroup(5) # needs sage.libs.gap # optional - gap_package_polycyclic
1598-
Multiplicative Abelian subgroup isomorphic to C5 x C5 x C5 generated by {f2^6, f4^42, f5^462}
1588+
Multiplicative Abelian subgroup isomorphic to C5 x C5 x C5
1589+
generated by {f2^6, f4^42, f5^462}
15991590
"""
16001591
if n is None:
16011592
torsion_generators = [g for g in self.gens() if g.order() != infinity]
@@ -1615,7 +1606,7 @@ def torsion_subgroup(self, n=None):
16151606

16161607
class AbelianGroup_subgroup(AbelianGroup_class):
16171608
"""
1618-
Subgroup subclass of AbelianGroup_class, so instance methods are
1609+
Subgroup subclass of ``AbelianGroup_class``, so instance methods are
16191610
inherited.
16201611
16211612
.. TODO::
@@ -1787,11 +1778,9 @@ def __contains__(self, x):
17871778

17881779
def ambient_group(self):
17891780
"""
1790-
Return the ambient group related to self.
1781+
Return the ambient group related to ``self``.
17911782
1792-
OUTPUT:
1793-
1794-
A multiplicative Abelian group.
1783+
OUTPUT: a multiplicative Abelian group
17951784
17961785
EXAMPLES::
17971786
@@ -1809,11 +1798,11 @@ def equals(left, right):
18091798
18101799
INPUT:
18111800
1812-
- ``right`` -- anything.
1801+
- ``right`` -- anything
18131802
18141803
OUTPUT:
18151804
1816-
Boolean. If ``right`` is a subgroup, test whether ``left`` and
1805+
boolean; if ``right`` is a subgroup, test whether ``left`` and
18171806
``right`` are the same subset of the ambient group. If
18181807
``right`` is not a subgroup, test whether they are isomorphic
18191808
groups, see :meth:`~AbelianGroup_class.is_isomorphic`.
@@ -1855,7 +1844,7 @@ def equals(left, right):
18551844

18561845
def _repr_(self):
18571846
"""
1858-
Return a string representation
1847+
Return a string representation.
18591848
18601849
EXAMPLES::
18611850
@@ -1879,9 +1868,7 @@ def gens(self) -> tuple:
18791868
"""
18801869
Return the generators for this subgroup.
18811870
1882-
OUTPUT:
1883-
1884-
A tuple of group elements generating the subgroup.
1871+
OUTPUT: tuple of group elements generating the subgroup
18851872
18861873
EXAMPLES::
18871874

0 commit comments

Comments
 (0)