Skip to content

Commit 671ad2c

Browse files
committed
minor doc tweaks in factorization
1 parent 81fbffe commit 671ad2c

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

src/sage/structure/factorization.py

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -219,24 +219,25 @@ def __init__(self, x, unit=None, cr=False, sort=True, simplify=True):
219219
220220
INPUT:
221221
222-
- ``x`` - a list of pairs (p, e) with e an integer;
223-
otherwise a TypeError is raised
222+
- ``x`` -- a list of pairs (p, e) with e an integer;
223+
otherwise a :class:`TypeError` is raised
224224
225-
- ``unit`` - (default: 1) the unit part of the factorization.
225+
- ``unit`` -- (default: 1) the unit part of the factorization.
226226
227-
- ``cr`` - (default: False) if True, print the factorization with
228-
carriage returns between factors.
227+
- ``cr`` -- (default: ``False``) if ``True``, print the factorization
228+
with carriage returns between factors.
229229
230-
- ``sort`` - (default: True) if True, sort the factors by calling
231-
the sort function ``self.sort()`` after creating the factorization
230+
- ``sort`` - (default: ``True``) if ``True``, sort the factors by
231+
calling the sort function ``self.sort()`` after creating
232+
the factorization
232233
233-
- ``simplify`` - (default: True) if True, remove duplicate
234+
- ``simplify`` - (default: ``True``) if ``True``, remove duplicate
234235
factors from the factorization. See the documentation for
235236
self.simplify.
236237
237238
OUTPUT:
238239
239-
- a Factorization object
240+
a Factorization object
240241
241242
EXAMPLES:
242243
@@ -319,7 +320,7 @@ def __init__(self, x, unit=None, cr=False, sort=True, simplify=True):
319320

320321
def __getitem__(self, i):
321322
"""
322-
Return `i^{th}` factor of self.
323+
Return `i^{th}` factor of ``self``.
323324
324325
EXAMPLES::
325326
@@ -340,7 +341,7 @@ def __getitem__(self, i):
340341

341342
def __setitem__(self, i, v):
342343
"""
343-
Set the `i^{th}` factor of self.
344+
Set the `i^{th}` factor of ``self``.
344345
345346
.. warning::
346347
@@ -359,7 +360,7 @@ def __setitem__(self, i, v):
359360

360361
def __len__(self):
361362
"""
362-
Return the number of prime factors of self, not counting
363+
Return the number of prime factors of ``self``, not counting
363364
the unit part.
364365
365366
EXAMPLES::
@@ -435,11 +436,11 @@ def __richcmp__(self, other, op):
435436

436437
def __copy__(self):
437438
r"""
438-
Return a copy of self.
439+
Return a copy of ``self``.
439440
440441
This is *not* a deepcopy -- only references to the factors are
441442
returned, not copies of them. Use ``deepcopy(self)`` if you need
442-
a deep copy of self.
443+
a deep copy of ``self``.
443444
444445
EXAMPLES:
445446
@@ -469,7 +470,7 @@ def __copy__(self):
469470

470471
def __deepcopy__(self, memo):
471472
r"""
472-
Return a deep copy of self.
473+
Return a deep copy of ``self``.
473474
474475
EXAMPLES:
475476
@@ -537,7 +538,7 @@ def universe(self):
537538

538539
def base_change(self, U):
539540
"""
540-
Return the factorization self, with its factors (including the
541+
Return the factorization ``self``, with its factors (including the
541542
unit part) coerced into the universe `U`.
542543
543544
EXAMPLES::
@@ -549,7 +550,7 @@ def base_change(self, U):
549550
sage: F.base_change(P).universe()
550551
Univariate Polynomial Ring in x over Integer Ring
551552
552-
This method will return a TypeError if the coercion is not
553+
This method will return a :class:`TypeError` if the coercion is not
553554
possible::
554555
555556
sage: g = x^2 - 1
@@ -571,7 +572,7 @@ def base_change(self, U):
571572

572573
def is_commutative(self) -> bool:
573574
"""
574-
Return True if my factors commute.
575+
Return ``True`` if my factors commute.
575576
576577
EXAMPLES::
577578
@@ -650,7 +651,7 @@ def sort(self, key=None):
650651
651652
INPUT:
652653
653-
- ``key`` - (default: ``None``) comparison key
654+
- ``key`` -- (default: ``None``) comparison key
654655
655656
OUTPUT:
656657
@@ -800,7 +801,7 @@ def _repr_(self):
800801
sage: f
801802
factorization of -100
802803
803-
However _repr_ always prints normally::
804+
However ``_repr_`` always prints normally::
804805
805806
sage: f._repr_()
806807
'-1 * 2^2 * 5^2'
@@ -924,7 +925,7 @@ def __pari__(self):
924925

925926
def __add__(self, other):
926927
"""
927-
Return the (unfactored) sum of self and other.
928+
Return the (unfactored) sum of ``self`` and ``other``.
928929
929930
EXAMPLES::
930931
@@ -941,7 +942,7 @@ def __add__(self, other):
941942

942943
def __sub__(self, other):
943944
"""
944-
Return the (unfactored) difference of self and other.
945+
Return the (unfactored) difference of ``self`` and ``other``.
945946
946947
EXAMPLES::
947948
@@ -956,7 +957,7 @@ def __sub__(self, other):
956957

957958
def __radd__(self, left):
958959
"""
959-
Return the (unfactored) sum of self and left.
960+
Return the (unfactored) sum of ``self`` and ``left``.
960961
961962
EXAMPLES::
962963
@@ -967,7 +968,7 @@ def __radd__(self, left):
967968

968969
def __rsub__(self, left):
969970
"""
970-
Return the (unfactored) difference of left and self.
971+
Return the (unfactored) difference of ``left`` and ``self``.
971972
972973
EXAMPLES::
973974
@@ -995,7 +996,7 @@ def __neg__(self):
995996

996997
def __rmul__(self, left):
997998
"""
998-
Return the product left * self, where left is not a Factorization.
999+
Return the product ``left * self``, where ``left`` is not a Factorization.
9991000
10001001
EXAMPLES::
10011002
@@ -1028,7 +1029,7 @@ def __mul__(self, other):
10281029
10291030
If the two factorizations have different universes, this
10301031
method will attempt to find a common universe for the
1031-
product. A TypeError is raised if this is impossible.
1032+
product. A :class:`TypeError` is raised if this is impossible.
10321033
10331034
EXAMPLES::
10341035
@@ -1179,6 +1180,8 @@ def __call__(self, *args, **kwds):
11791180
"""
11801181
Implement the substitution.
11811182
1183+
This is assuming that each term can be substituted.
1184+
11821185
There is another mechanism for substitution
11831186
in symbolic products.
11841187
@@ -1240,7 +1243,7 @@ def gcd(self, other):
12401243
12411244
If the two factorizations have different universes, this
12421245
method will attempt to find a common universe for the
1243-
gcd. A TypeError is raised if this is impossible.
1246+
gcd. A :class:`TypeError` is raised if this is impossible.
12441247
12451248
EXAMPLES::
12461249
@@ -1282,7 +1285,7 @@ def lcm(self, other):
12821285
12831286
If the two factorizations have different universes, this
12841287
method will attempt to find a common universe for the
1285-
lcm. A TypeError is raised if this is impossible.
1288+
lcm. A :class:`TypeError` is raised if this is impossible.
12861289
12871290
EXAMPLES::
12881291
@@ -1320,7 +1323,7 @@ def lcm(self, other):
13201323

13211324
def is_integral(self) -> bool:
13221325
r"""
1323-
Return True iff all exponents of this Factorization are non-negative.
1326+
Return whether all exponents of this Factorization are non-negative.
13241327
13251328
EXAMPLES::
13261329
@@ -1338,11 +1341,11 @@ def is_integral(self) -> bool:
13381341

13391342
def radical(self):
13401343
"""
1341-
Return the factorization of the radical of the value of self.
1344+
Return the factorization of the radical of the value of ``self``.
13421345
13431346
First, check that all exponents in the factorization are
1344-
positive, raise ValueError otherwise. If all exponents are
1345-
positive, return self with all exponents set to 1 and with the
1347+
positive, raise :class:`ValueError` otherwise. If all exponents are
1348+
positive, return ``self`` with all exponents set to 1 and with the
13461349
unit set to 1.
13471350
13481351
EXAMPLES::
@@ -1358,18 +1361,18 @@ def radical(self):
13581361
"""
13591362
if not all(e > 0 for _, e in self.__x):
13601363
raise ValueError("all exponents in the factorization must be positive")
1361-
return Factorization([(p, 1) for p, e in self.__x], unit=self.unit().parent()(1),
1364+
return Factorization([(p, 1) for p, _ in self.__x], unit=self.unit().parent()(1),
13621365
cr=self.__cr, sort=False, simplify=False)
13631366

13641367
def radical_value(self):
13651368
"""
1366-
Return the product of the prime factors in self.
1369+
Return the product of the prime factors in ``self``.
13671370
13681371
First, check that all exponents in the factorization are
1369-
positive, raise ValueError otherwise. If all exponents are
1370-
positive, return the product of the prime factors in self.
1372+
positive, raise :class:`ValueError` otherwise. If all exponents are
1373+
positive, return the product of the prime factors in ``self``.
13711374
This should be functionally equivalent to
1372-
self.radical().value()
1375+
``self.radical().value()``.
13731376
13741377
EXAMPLES::
13751378

0 commit comments

Comments
 (0)