Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit dbfde86

Browse files
author
Frédéric Chapoton
committed
py3: fix some remaining invalid escape sequences
1 parent 8b4f9a0 commit dbfde86

File tree

6 files changed

+27
-20
lines changed

6 files changed

+27
-20
lines changed

src/sage/all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def _write_started_file():
306306
module='.*(IPython|ipykernel|jupyter_client|jupyter_core|nbformat|notebook|ipywidgets|storemagic)')
307307
# However, be sure to keep OUR deprecation warnings
308308
warnings.filterwarnings('default',
309-
'[\s\S]*See http://trac.sagemath.org/[0-9]* for details.')
309+
r'[\s\S]*See https\?://trac.sagemath.org/[0-9]* for details.')
310310

311311

312312
# Set a new random number seed as the very last thing

src/sage/combinat/root_system/type_Q.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def __reduce__(self):
7676
return (CartanType, (self.letter, self.n+1))
7777

7878
def index_set(self):
79-
"""
80-
Returns index set for Cartan type Q.
79+
r"""
80+
Return the index set for Cartan type Q.
8181
8282
The index set for type Q is of the form
8383
`\{-n, \ldots, -1, 1, \ldots, n\}`.
@@ -87,7 +87,7 @@ def index_set(self):
8787
sage: CartanType(['Q', 3]).index_set()
8888
(1, 2, -2, -1)
8989
"""
90-
return tuple(range(1,self.n+1)+range(-self.n,0))
90+
return tuple(range(1, self.n + 1) + range(-self.n, 0))
9191

9292
def _latex_(self):
9393
r"""
@@ -98,7 +98,7 @@ def _latex_(self):
9898
sage: latex(CartanType(['Q',4]))
9999
Q_{4}
100100
"""
101-
return "Q_{%s}"%(self.n+1)
101+
return "Q_{%s}" % (self.n + 1)
102102

103103
def root_system(self):
104104
"""

src/sage/env.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
Sage Runtime Environment
33
44
AUTHORS:
@@ -227,6 +227,7 @@ def _add_variable_or_fallback(key, fallback, force=False):
227227
# delete temporary variables used for setting up sage.env
228228
del opj, os, socket, version, site
229229

230+
230231
def sage_include_directories(use_sources=False):
231232
"""
232233
Return the list of include directories for compiling Sage extension modules.

src/sage/misc/latex.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def str_function(x):
330330
return x
331331
# Deal with special characters
332332
char_wrapper = r"{\char`\%s}"
333-
x = "".join(char_wrapper % c if c in "#$%&\^_{}~" else c for c in x)
333+
x = "".join(char_wrapper % c if c in r"#$%&\^_{}~" else c for c in x)
334334
# Avoid grouping spaces into one
335335
x = x.replace(" ", "{ }")
336336
# And dashes too, since it causes issues for the command line...
@@ -865,8 +865,9 @@ def _run_latex_(filename, debug=False, density=150, engine=None, png=False, do_i
865865
return "Error latexing slide."
866866
return return_suffix
867867

868+
868869
class LatexCall:
869-
"""
870+
r"""
870871
Typeset Sage objects via a ``__call__`` method to this class,
871872
typically by calling those objects' ``_latex_`` methods. The
872873
class :class:`Latex` inherits from this. This class is used in
@@ -1964,7 +1965,7 @@ def eval(self, x, globals=None, locals=None, mode='display',
19641965
# part should end in "}}", so omit the last two characters
19651966
# from y
19661967
y = part[:closing-1]
1967-
for delimiter in """|"'`#%&,.:;?!@_~^+-/\=<>()[]{}0123456789E""":
1968+
for delimiter in r"""|"'`#%&,.:;?!@_~^+-/\=<>()[]{}0123456789E""":
19681969
if delimiter not in y:
19691970
break
19701971
if delimiter == "E":
@@ -2420,7 +2421,7 @@ def repr_lincomb(symbols, coeffs):
24202421
# multiplication sign in
24212422
try:
24222423
if bv in CC:
2423-
s += "%s\cdot %s" % (coeff, b)
2424+
s += r"%s\cdot %s" % (coeff, b)
24242425
else:
24252426
s += "%s%s" % (coeff, b)
24262427
except Exception:
@@ -2615,7 +2616,7 @@ def latex_variable_name(x, is_fname=False):
26152616
# * The "\d|[.,]" means "decimal digit" or period or comma
26162617
# * The "+" means "1 or more"
26172618
# * The "$" means "at the end of the line"
2618-
m = re.search('(\d|[.,])+$',x)
2619+
m = re.search(r'(\d|[.,])+$', x)
26192620
if m is None:
26202621
prefix = x
26212622
suffix = None
@@ -2630,15 +2631,16 @@ def latex_variable_name(x, is_fname=False):
26302631
for sym in symtable.values():
26312632
if sym[0] == '_' and sym[1:] == suffix:
26322633
return latex_variable_name(suffix)
2633-
if suffix and len(suffix) > 0:
2634+
if suffix and len(suffix):
26342635
# handle the suffix specially because it very well might be numeric
26352636
# I use strip to avoid using regex's -- It makes it a bit faster (and the code is more comprehensible to non-regex'ed people)
2636-
if suffix.strip("1234567890")!="":
2637+
if suffix.strip("1234567890") != "":
26372638
suffix = latex_variable_name(suffix, is_fname) # recurse to deal with recursive subscripts
2638-
return '%s_{%s}'%(latex_varify(prefix, is_fname), suffix)
2639+
return '%s_{%s}' % (latex_varify(prefix, is_fname), suffix)
26392640
else:
26402641
return latex_varify(prefix, is_fname)
26412642

2643+
26422644
class LatexExamples():
26432645
r"""
26442646
A catalogue of Sage objects with complicated ``_latex_`` methods.

src/sage/modular/modform/ambient.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,11 @@ def _q_expansion(self, element, prec):
558558
####################################################################
559559
@cached_method
560560
def _dim_cuspidal(self):
561-
"""
561+
r"""
562562
Return the dimension of the cuspidal subspace of this ambient
563-
modular forms space. For weights `k \ge 2` this is computed using a
563+
modular forms space.
564+
565+
For weights `k \ge 2` this is computed using a
564566
dimension formula. For weight 1, it will trigger a computation of a
565567
basis of `q`-expansions using Schaeffer's algorithm, unless this space
566568
is a space of Eisenstein forms only, in which case we just return 0.
@@ -583,7 +585,8 @@ def _dim_cuspidal(self):
583585
if self._eis_only:
584586
return 0
585587
if arithgroup.is_Gamma1(self.group()) and self.character() is not None:
586-
return self.group().dimension_cusp_forms(self.weight(), self.character())
588+
return self.group().dimension_cusp_forms(self.weight(),
589+
self.character())
587590
else:
588591
return self.group().dimension_cusp_forms(self.weight())
589592

src/sage/schemes/elliptic_curves/isogeny_small_degree.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ def isogenies_2(E, minimal_models=True):
708708

709709

710710
def isogenies_3(E, minimal_models=True):
711-
"""
711+
r"""
712712
Return a list of all 3-isogenies with domain ``E``.
713713
714714
INPUT:
@@ -748,7 +748,7 @@ def isogenies_3(E, minimal_models=True):
748748
f3 = E.division_polynomial(3)
749749
x3 = sorted(f3.roots(multiplicities=False))
750750
x = f3.parent().gen()
751-
ff = [x-x3i for x3i in x3]
751+
ff = [x - x3i for x3i in x3]
752752
from sage.rings.number_field.number_field_base import is_NumberField
753753
model = "minimal" if minimal_models and is_NumberField(E.base_field()) else None
754754
isogs = [E.isogeny(f, model=model) for f in ff]
@@ -757,7 +757,8 @@ def isogenies_3(E, minimal_models=True):
757757
# 6 special cases: `l` = 5, 7, 13 and `j` = 0, 1728.
758758

759759
def isogenies_5_0(E, minimal_models=True):
760-
r"""Returns a list of all the 5-isogenies with domain ``E`` when the
760+
r"""
761+
Return a list of all the 5-isogenies with domain ``E`` when the
761762
j-invariant is 0.
762763
763764
INPUT:

0 commit comments

Comments
 (0)