Skip to content

Commit 662d799

Browse files
Use raw strings in place of backslash-escapes
Exception: don’t touch doc/devel/tools/tricked_out_emacs.rst for now.
1 parent 1e5cb60 commit 662d799

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

nipy/algorithms/statistics/formula/formulae.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def __add__(self, other):
202202

203203

204204
def terms(names, **kwargs):
205-
''' Return list of terms with names given by `names`
205+
r''' Return list of terms with names given by `names`
206206
207207
This is just a convenience in defining a set of terms, and is the
208208
equivalent of ``sympy.symbols`` for defining symbols in sympy.
@@ -215,7 +215,7 @@ def terms(names, **kwargs):
215215
names : str or sequence of str
216216
If a single str, can specify multiple ``Term``s with string
217217
containing space or ',' as separator.
218-
\\**kwargs : keyword arguments
218+
\**kwargs : keyword arguments
219219
keyword arguments as for ``sympy.symbols``
220220
221221
Returns

nipy/core/reference/coordinate_map.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,22 +2301,22 @@ def make_cmap(self, domain_N, xform, inv_xform=None):
23012301
inv_xform)
23022302

23032303
def __call__(self, *args, **kwargs):
2304-
""" Create affine or non-affine coordinate map
2304+
r""" Create affine or non-affine coordinate map
23052305
23062306
Parameters
23072307
----------
2308-
\\*args :
2308+
\*args :
23092309
Arguments to ``make_affine`` or ``make_cmap`` methods. We check the
23102310
first argument to see if it is a scalar or an affine, and pass the
2311-
\\*args, \\*\\*kwargs to ``make_cmap`` or ``make_affine``
2311+
\*args, \*\*kwargs to ``make_cmap`` or ``make_affine``
23122312
respectively
2313-
\\*\\*kwargs:
2313+
\*\*kwargs:
23142314
See above
23152315
23162316
Returns
23172317
-------
23182318
cmap : ``CoordinateMap`` or ``AffineTransform``
2319-
Affine if the first \\*arg was an affine array, otherwise a
2319+
Affine if the first \*arg was an affine array, otherwise a
23202320
Coordinate Map.
23212321
"""
23222322
arg0 = np.asarray(args[0])

nipy/modalities/fmri/design.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,13 @@ def stack_contrasts(contrasts, name, keys):
402402

403403

404404
def stack_designs(*pairs):
405-
""" Stack a sequence of design / contrast dictionary pairs
405+
r""" Stack a sequence of design / contrast dictionary pairs
406406
407407
Uses multiple calls to :func:`stack2designs`
408408
409409
Parameters
410410
----------
411-
\\*pairs : sequence
411+
\*pairs : sequence
412412
Elements of either (np.ndarray, dict) or (np.ndarray,) or np.ndarray
413413
414414
Returns

nipy/modalities/fmri/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def fourier_basis(freq):
142142

143143

144144
def interp(times, values, fill=0, name=None, **kw):
145-
""" Generic interpolation function of t given `times` and `values`
145+
r""" Generic interpolation function of t given `times` and `values`
146146
147147
Imterpolator such that:
148148
@@ -167,7 +167,7 @@ def interp(times, values, fill=0, name=None, **kw):
167167
error outside bounds
168168
name : None or str, optional
169169
Name of symbolic expression to use. If None, a default is used.
170-
\\*\\*kw : keyword args, optional
170+
\*\*kw : keyword args, optional
171171
passed to ``interp1d``
172172
173173
Returns
@@ -206,7 +206,7 @@ def interp(times, values, fill=0, name=None, **kw):
206206

207207

208208
def linear_interp(times, values, fill=0, name=None, **kw):
209-
""" Linear interpolation function of t given `times` and `values`
209+
r""" Linear interpolation function of t given `times` and `values`
210210
211211
Imterpolator such that:
212212
@@ -229,7 +229,7 @@ def linear_interp(times, values, fill=0, name=None, **kw):
229229
error outside bounds
230230
name : None or str, optional
231231
Name of symbolic expression to use. If None, a default is used.
232-
\\*\\*kw : keyword args, optional
232+
\*\*kw : keyword args, optional
233233
passed to ``interp1d``
234234
235235
Returns
@@ -455,7 +455,7 @@ def __init__(self, expr, support, delta, fill=0):
455455
self._vals = _eval_for(expr, self.support, self.delta)
456456

457457
def convolve(self, g, g_interval, name=None, **kwargs):
458-
""" Convolve sympy expression `g` with this kernel
458+
r""" Convolve sympy expression `g` with this kernel
459459
460460
Parameters
461461
----------
@@ -466,7 +466,7 @@ def convolve(self, g, g_interval, name=None, **kwargs):
466466
name : None or str, optional
467467
Name of the convolved function in the resulting expression.
468468
Defaults to one created by ``utils.interp``.
469-
\\*\\*kwargs : keyword args, optional
469+
\*\*kwargs : keyword args, optional
470470
Any other arguments to pass to the ``interp1d`` function in creating
471471
the numerical function for `fg`.
472472
@@ -488,7 +488,7 @@ def convolve(self, g, g_interval, name=None, **kwargs):
488488

489489
def convolve_functions(f, g, f_interval, g_interval, dt,
490490
fill=0, name=None, **kwargs):
491-
""" Expression containing numerical convolution of `fn1` with `fn2`
491+
r""" Expression containing numerical convolution of `fn1` with `fn2`
492492
493493
Parameters
494494
----------
@@ -508,7 +508,7 @@ def convolve_functions(f, g, f_interval, g_interval, dt,
508508
name : None or str, optional
509509
Name of the convolved function in the resulting expression.
510510
Defaults to one created by ``utils.interp``.
511-
\\*\\*kwargs : keyword args, optional
511+
\*\*kwargs : keyword args, optional
512512
Any other arguments to pass to the ``interp1d`` function in creating the
513513
numerical function for `fg`.
514514

nipy/utils/perlpie.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3-
"""Perform a global search and replace on the current directory *recursively*.
3+
r"""Perform a global search and replace on the current directory *recursively*.
44
55
This a small python wrapper around the `perl -p -i -e` functionality.
66
I **strongly recommend** running `perlpie` on files under source
@@ -36,16 +36,16 @@
3636
3737
Replace numpy.testing with nipy's testing framework::
3838
39-
perlpie 'from\\s+numpy\\.testing.*' 'from nipy.testing import *'
39+
perlpie 'from\s+numpy\.testing.*' 'from nipy.testing import *'
4040
4141
Replace all @slow decorators in my code with @dec.super_slow. Here we
4242
have to escape the @ symbol which has special meaning in perl::
4343
44-
perlpie '\\@slow' '\\@dec.super_slow'
44+
perlpie '\@slow' '\@dec.super_slow'
4545
4646
Remove all occurences of importing make_doctest_suite::
4747
48-
perlpie 'from\\snipy\\.utils\\.testutils.*make_doctest_suite'
48+
perlpie 'from\snipy\.utils\.testutils.*make_doctest_suite'
4949
5050
"""
5151

@@ -71,15 +71,15 @@ def check_deps():
7171

7272

7373
def perl_dash_pie(oldstr, newstr, dry_run=None):
74-
"""Use perl to replace the oldstr with the newstr.
74+
r"""Use perl to replace the oldstr with the newstr.
7575
7676
Examples
7777
--------
7878
7979
# To replace all occurences of 'import numpy as N' with 'import numpy as np'
8080
from nipy.utils import perlpie
81-
perlpie.perl_dash_pie('import\\s+numpy\\s+as\\s+N', 'import numpy as np')
82-
grind | xargs perl -pi -e 's/import\\s+numpy\\s+as\\s+N/import numpy as np/g'
81+
perlpie.perl_dash_pie('import\s+numpy\s+as\s+N', 'import numpy as np')
82+
grind | xargs perl -pi -e 's/import\s+numpy\s+as\s+N/import numpy as np/g'
8383
8484
"""
8585

tools/apigen.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def __init__(self,
6868
['\.setup$', '\._']
6969
'''
7070
if package_skip_patterns is None:
71-
package_skip_patterns = ['\\.tests$']
71+
package_skip_patterns = [r'\.tests$']
7272
if module_skip_patterns is None:
73-
module_skip_patterns = ['\\.setup$', '\\._']
73+
module_skip_patterns = [r'\.setup$', r'\._']
7474
self.package_name = package_name
7575
self.rst_extension = rst_extension
7676
self.package_skip_patterns = package_skip_patterns
@@ -272,7 +272,7 @@ def generate_api_doc(self, uri):
272272
return ad
273273

274274
def _survives_exclude(self, matchstr, match_type):
275-
''' Returns True if *matchstr* does not match patterns
275+
r''' Returns True if *matchstr* does not match patterns
276276
277277
``self.package_name`` removed from front of string if present
278278
@@ -281,14 +281,14 @@ def _survives_exclude(self, matchstr, match_type):
281281
>>> dw = ApiDocWriter('sphinx')
282282
>>> dw._survives_exclude('sphinx.okpkg', 'package')
283283
True
284-
>>> dw.package_skip_patterns.append('^\\.badpkg$')
284+
>>> dw.package_skip_patterns.append(r'^\.badpkg$')
285285
>>> dw._survives_exclude('sphinx.badpkg', 'package')
286286
False
287287
>>> dw._survives_exclude('sphinx.badpkg', 'module')
288288
True
289289
>>> dw._survives_exclude('sphinx.badmod', 'module')
290290
True
291-
>>> dw.module_skip_patterns.append('^\\.badmod$')
291+
>>> dw.module_skip_patterns.append(r'^\.badmod$')
292292
>>> dw._survives_exclude('sphinx.badmod', 'module')
293293
False
294294
'''

0 commit comments

Comments
 (0)