Skip to content

Commit 9cde032

Browse files
author
Release Manager
committed
sagemathgh-41459: Fix docstring formatting to raw string literals <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Fix a few missing `r-strings` for docs, found by running pytest and those changes here are extracted from sagemath#36981. Also includes a few other minor linter fixes in the touched files. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#41459 Reported by: Tobias Diez Reviewer(s): Frédéric Chapoton
2 parents 6434630 + c45652c commit 9cde032

File tree

7 files changed

+52
-49
lines changed

7 files changed

+52
-49
lines changed

src/sage/graphs/dot2tex_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
# ****************************************************************************
1010

1111
import re
12-
from sage.misc.latex import latex
12+
1313
from sage.misc.cachefunc import cached_function
14+
from sage.misc.latex import latex
1415

1516

1617
@cached_function
@@ -68,7 +69,7 @@ def assert_have_dot2tex():
6869

6970

7071
def quoted_latex(x):
71-
"""
72+
r"""
7273
Strips the latex representation of ``x`` to make it suitable for a
7374
``dot2tex`` string.
7475

src/sage/graphs/graph_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def from_graph6(data, immutable=False):
168168

169169

170170
def from_sparse6(data, immutable=False):
171-
"""
171+
r"""
172172
Return a list of Sage Graphs, given a list of sparse6 data.
173173
174174
INPUT:

src/sage/groups/matrix_gps/named_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _repr_(self):
256256
return self._name_string
257257

258258
def _latex_(self):
259-
"""
259+
r"""
260260
Return a LaTeX representation.
261261
262262
OUTPUT: string

src/sage/homology/chain_complex.py

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,22 @@
4949
from copy import copy
5050
from functools import reduce
5151

52-
from sage.structure.parent import Parent
53-
from sage.structure.element import ModuleElement, Vector, coercion_model
52+
from sage.homology.homology_group import HomologyGroup
53+
from sage.matrix.constructor import matrix
54+
from sage.matrix.matrix0 import Matrix
5455
from sage.misc.cachefunc import cached_method
55-
56-
from sage.rings.integer_ring import ZZ
56+
from sage.misc.latex import latex
57+
from sage.misc.persist import register_unpickle_override
5758
from sage.modules.free_module import FreeModule
5859
from sage.modules.free_module_element import vector
59-
from sage.matrix.matrix0 import Matrix
60-
from sage.matrix.constructor import matrix
61-
from sage.misc.latex import latex
6260
from sage.rings.fast_arith import prime_range
63-
from sage.homology.homology_group import HomologyGroup
64-
from sage.misc.persist import register_unpickle_override
61+
from sage.rings.integer_ring import ZZ
62+
from sage.structure.element import ModuleElement, Vector, coercion_model
63+
from sage.structure.parent import Parent
6564

6665

6766
def _latex_module(R, m):
68-
"""
67+
r"""
6968
LaTeX string representing a free module over ``R`` of rank ``m``.
7069
7170
INPUT:
@@ -1321,35 +1320,34 @@ def change_ring(X):
13211320
for order, gen in zip(orders, gens)]
13221321
else:
13231322
answer = []
1324-
else:
1325-
if base_ring.is_field():
1326-
d_in_rank = self.rank(deg-differential, ring=base_ring)
1327-
answer = HomologyGroup(d_out_nullity - d_in_rank, base_ring)
1328-
elif base_ring == ZZ:
1329-
if d_in.ncols() == 0:
1330-
all_divs = [0] * d_out_nullity
1331-
else:
1332-
if algorithm in ['auto', 'no_chomp']:
1333-
if ((d_in.ncols() > 300 and d_in.nrows() > 300)
1334-
or (min(d_in.ncols(), d_in.nrows()) > 100 and
1335-
d_in.ncols() + d_in.nrows() > 600)):
1336-
algorithm = 'dhsw'
1337-
else:
1338-
algorithm = 'pari'
1339-
if algorithm == 'dhsw':
1340-
from sage.homology.matrix_utils import dhsw_snf
1341-
all_divs = dhsw_snf(d_in, verbose=verbose)
1342-
elif algorithm == 'pari':
1343-
all_divs = d_in.elementary_divisors(algorithm)
1344-
else:
1345-
raise ValueError('unsupported algorithm')
1346-
all_divs = all_divs[:d_out_nullity]
1347-
# divisors equal to 1 produce trivial
1348-
# summands, so filter them out
1349-
divisors = [x for x in all_divs if x != 1]
1350-
answer = HomologyGroup(len(divisors), base_ring, divisors)
1323+
elif base_ring.is_field():
1324+
d_in_rank = self.rank(deg-differential, ring=base_ring)
1325+
answer = HomologyGroup(d_out_nullity - d_in_rank, base_ring)
1326+
elif base_ring == ZZ:
1327+
if d_in.ncols() == 0:
1328+
all_divs = [0] * d_out_nullity
13511329
else:
1352-
raise NotImplementedError('only base rings ZZ and fields are supported')
1330+
if algorithm in ['auto', 'no_chomp']:
1331+
if ((d_in.ncols() > 300 and d_in.nrows() > 300)
1332+
or (min(d_in.ncols(), d_in.nrows()) > 100 and
1333+
d_in.ncols() + d_in.nrows() > 600)):
1334+
algorithm = 'dhsw'
1335+
else:
1336+
algorithm = 'pari'
1337+
if algorithm == 'dhsw':
1338+
from sage.homology.matrix_utils import dhsw_snf
1339+
all_divs = dhsw_snf(d_in, verbose=verbose)
1340+
elif algorithm == 'pari':
1341+
all_divs = d_in.elementary_divisors(algorithm)
1342+
else:
1343+
raise ValueError('unsupported algorithm')
1344+
all_divs = all_divs[:d_out_nullity]
1345+
# divisors equal to 1 produce trivial
1346+
# summands, so filter them out
1347+
divisors = [x for x in all_divs if x != 1]
1348+
answer = HomologyGroup(len(divisors), base_ring, divisors)
1349+
else:
1350+
raise NotImplementedError('only base rings ZZ and fields are supported')
13531351
return answer
13541352

13551353
def _homology_generators_snf(self, d_in, d_out, d_out_rank):
@@ -1769,7 +1767,7 @@ def module_art(n):
17691767
return concatenated
17701768

17711769
def _latex_(self):
1772-
"""
1770+
r"""
17731771
LaTeX print representation.
17741772
17751773
EXAMPLES::

src/sage/interfaces/expect.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import sage.interfaces.abc
5656
from sage.cpython.string import bytes_to_str, str_to_bytes
5757
from sage.env import LOCAL_IDENTIFIER, SAGE_EXTCODE
58+
from sage.interfaces import quit
5859
from sage.interfaces.interface import (
5960
Interface,
6061
InterfaceElement,
@@ -65,8 +66,6 @@
6566
from sage.misc.object_multiplexer import Multiplex
6667
from sage.structure.element import RingElement
6768

68-
from . import quit
69-
7069
BAD_SESSION = -2
7170

7271
# The subprocess is a shared resource. In a multi-threaded
@@ -693,7 +692,7 @@ def detach(self):
693692
self._reset_expect()
694693

695694
def _quit_string(self):
696-
"""
695+
r"""
697696
Return the string which will be used to quit the application.
698697
699698
EXAMPLES::

src/sage/interfaces/gp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@
149149

150150
lazy_import('sage.rings.cc', 'CC')
151151

152-
from .expect import Expect, ExpectElement, ExpectFunction, FunctionElement
152+
from sage.interfaces.expect import (
153+
Expect,
154+
ExpectElement,
155+
ExpectFunction,
156+
FunctionElement,
157+
)
153158

154159

155160
class Gp(ExtraTabCompletion, Expect):
@@ -308,7 +313,7 @@ def _function_class(self):
308313
return GpFunction
309314

310315
def _quit_string(self):
311-
"""
316+
r"""
312317
Return the string used to quit the GP interpreter.
313318
314319
EXAMPLES::

src/sage/interfaces/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ def __reduce__(self):
831831
return self.parent(), (self._reduce(),)
832832

833833
def _reduce(self):
834-
"""
834+
r"""
835835
Helper for pickling.
836836
837837
By default, if ``self`` is a string, then the representation of

0 commit comments

Comments
 (0)