Skip to content

Commit cca7371

Browse files
committed
RF+DOC: PEP8 / docstring fixes from Eric's review
Use 'A is not None' instead of 'not A is None'. Fix incorrect docstring mentions of 'r+'.
1 parent 744c631 commit cca7371

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

nibabel/analyze.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ def from_file_map(klass, file_map, mmap=True):
938938
-------
939939
img : AnalyzeImage instance
940940
'''
941-
if not mmap in (True, False, 'c', 'r'):
941+
if mmap not in (True, False, 'c', 'r'):
942942
raise ValueError("mmap should be one of {True, False, 'c', 'r'}")
943943
hdr_fh, img_fh = klass._get_fileholders(file_map)
944944
with hdr_fh.get_prepare_fileobj(mode='rb') as hdrf:
@@ -978,7 +978,7 @@ def from_filename(klass, filename, mmap=True):
978978
-------
979979
img : Analyze Image instance
980980
'''
981-
if not mmap in (True, False, 'c', 'r'):
981+
if mmap not in (True, False, 'c', 'r'):
982982
raise ValueError("mmap should be one of {True, False, 'c', 'r'}")
983983
file_map = klass.filespec_to_file_map(filename)
984984
return klass.from_file_map(file_map, mmap=mmap)

nibabel/arrayproxy.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class ArrayProxy(object):
5656
including Nifti1, and with the MGH format.
5757
5858
Other image types might need more specific classes to implement the API.
59-
API. See :mod:`nibabel.minc1` and :mod:`nibabel.ecat` for examples.
59+
See :mod:`nibabel.minc1`, :mod:`nibabel.ecat` and :mod:`nibabel.parrec` for
60+
examples.
6061
"""
6162
# Assume Fortran array memory layout
6263
order = 'F'
@@ -76,12 +77,14 @@ def __init__(self, file_like, header, mmap=True):
7677
mmap : {True, False, 'c', 'r'}, optional, keyword only
7778
`mmap` controls the use of numpy memory mapping for reading data.
7879
If False, do not try numpy ``memmap`` for data array. If one of
79-
{'c', 'r', 'r+'}, try numpy memmap with ``mode=mmap``. A `mmap`
80-
value of True gives the same behavior as ``mmap='c'``. If
81-
`file_like` cannot be memory-mapped, ignore `mmap` value and read
82-
array from file.
80+
{'c', 'r'}, try numpy memmap with ``mode=mmap``. A `mmap` value of
81+
True gives the same behavior as ``mmap='c'``. If `file_like`
82+
cannot be memory-mapped, ignore `mmap` value and read array from
83+
file.
84+
scaling : {'fp', 'dv'}, optional, keyword only
85+
Type of scaling to use - see header ``get_data_scaling`` method.
8386
"""
84-
if not mmap in (True, False, 'c', 'r'):
87+
if mmap not in (True, False, 'c', 'r'):
8588
raise ValueError("mmap should be one of {True, False, 'c', 'r'}")
8689
self.file_like = file_like
8790
# Copies of values needed to read array

nibabel/parrec.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def _data_from_rec(rec_fileobj, in_shape, dtype, slice_indices, out_shape,
463463
rec_data = array_from_file(in_shape, dtype, rec_fileobj, mmap=mmap)
464464
rec_data = rec_data[..., slice_indices]
465465
rec_data = rec_data.reshape(out_shape, order='F')
466-
if not scalings is None:
466+
if scalings is not None:
467467
# Don't do in-place b/c this goes int16 -> float64
468468
rec_data = rec_data * scalings[0] + scalings[1]
469469
return rec_data
@@ -485,14 +485,14 @@ def __init__(self, file_like, header, mmap=True, scaling='dv'):
485485
mmap : {True, False, 'c', 'r'}, optional, keyword only
486486
`mmap` controls the use of numpy memory mapping for reading data.
487487
If False, do not try numpy ``memmap`` for data array. If one of
488-
{'c', 'r', 'r+'}, try numpy memmap with ``mode=mmap``. A `mmap`
489-
value of True gives the same behavior as ``mmap='c'``. If
490-
`file_like` cannot be memory-mapped, ignore `mmap` value and read
491-
array from file.
488+
{'c', 'r'}, try numpy memmap with ``mode=mmap``. A `mmap` value of
489+
True gives the same behavior as ``mmap='c'``. If `file_like`
490+
cannot be memory-mapped, ignore `mmap` value and read array from
491+
file.
492492
scaling : {'fp', 'dv'}, optional, keyword only
493493
Type of scaling to use - see header ``get_data_scaling`` method.
494494
"""
495-
if not mmap in (True, False, 'c', 'r'):
495+
if mmap not in (True, False, 'c', 'r'):
496496
raise ValueError("mmap should be one of {True, False, 'c', 'r'}")
497497
self.file_like = file_like
498498
# Copies of values needed to read array

0 commit comments

Comments
 (0)