Skip to content

Commit 064cb7f

Browse files
author
Ben Cipollini
committed
STY: flake8 manual fixes
1 parent ee23aa2 commit 064cb7f

24 files changed

+67
-63
lines changed

nibabel/affines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def from_matvec(matrix, vector=None):
166166
t = np.zeros((nin + 1, nout + 1), matrix.dtype)
167167
t[0:nin, 0:nout] = matrix
168168
t[nin, nout] = 1.
169-
if not vector is None:
169+
if vector is not None:
170170
t[0:nin, nout] = vector
171171
return t
172172

nibabel/casting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def type_info(np_type):
269269
# Oh dear, we don't recognize the type information. Try some known types
270270
# and then give up. At this stage we're expecting exotic longdouble or
271271
# their complex equivalent.
272-
if not np_type in (np.longdouble, np.longcomplex) or width not in (16, 32):
272+
if np_type not in (np.longdouble, np.longcomplex) or width not in (16, 32):
273273
raise FloatingError('We had not expected type %s' % np_type)
274274
if (vals == (1, 1, 16) and on_powerpc() and
275275
_check_maxexp(np.longdouble, 1024)):
@@ -439,7 +439,7 @@ def int_to_float(val, flt_type):
439439
f : numpy scalar
440440
of type `flt_type`
441441
"""
442-
if not flt_type is np.longdouble:
442+
if flt_type is not np.longdouble:
443443
return flt_type(val)
444444
# The following works around a nasty numpy 1.4.1 bug such that:
445445
# >>> int(np.uint32(2**32-1)

nibabel/checkwarns.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
from .testing import (error_warnings, suppress_warnings)
1616

1717

18-
warnings.warn('The checkwarns module is deprecated and will be removed in nibabel v3.0', FutureWarning)
18+
warnings.warn('The checkwarns module is deprecated and will be removed '
19+
'in nibabel v3.0', FutureWarning)
1920

2021

2122
class ErrorWarnings(error_warnings):

nibabel/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def make_datasource(pkg_def, **kwargs):
298298
e)
299299
if 'name' in pkg_def:
300300
msg += '\n\nYou may need the package "%s"' % pkg_def['name']
301-
if not pkg_hint is None:
301+
if pkg_hint is not None:
302302
msg += '\n\n%s' % pkg_hint
303303
raise DataError(msg)
304304
return VersionedDatasource(pth)

nibabel/ecat.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,17 @@ def get_data_dtype(self):
305305

306306
def get_patient_orient(self):
307307
""" gets orientation of patient based on code stored
308-
in header, not always reliable"""
308+
in header, not always reliable
309+
"""
309310
code = self._structarr['patient_orientation'].item()
310-
if not code in self._patient_orient_codes:
311+
if code not in self._patient_orient_codes:
311312
raise KeyError('Ecat Orientation CODE %d not recognized' % code)
312313
return self._patient_orient_codes[code]
313314

314315
def get_filetype(self):
315316
""" Type of ECAT Matrix File from code stored in header"""
316317
code = self._structarr['file_type'].item()
317-
if not code in self._ft_codes:
318+
if code not in self._ft_codes:
318319
raise KeyError('Ecat Filetype CODE %d not recognized' % code)
319320
return self._ft_codes[code]
320321

@@ -368,7 +369,7 @@ def read_mlist(fileobj, endianness):
368369
`nused` in CTI code).
369370
"""
370371
dt = np.dtype(np.int32)
371-
if not endianness is native_code:
372+
if endianness is not native_code:
372373
dt = dt.newbyteorder(endianness)
373374
mlists = []
374375
mlist_index = 0
@@ -496,7 +497,7 @@ def read_subheaders(fileobj, mlist, endianness):
496497
"""
497498
subheaders = []
498499
dt = subhdr_dtype
499-
if not endianness is native_code:
500+
if endianness is not native_code:
500501
dt = dt.newbyteorder(endianness)
501502
for mat_id, sh_blkno, sh_last_blkno, mat_stat in mlist:
502503
if sh_blkno == 0:
@@ -630,7 +631,7 @@ def raw_data_from_fileobj(self, frame=0, orientation=None):
630631
.. seealso:: data_from_fileobj
631632
'''
632633
dtype = self._get_data_dtype(frame)
633-
if not self._header.endianness is native_code:
634+
if self._header.endianness is not native_code:
634635
dtype = dtype.newbyteorder(self._header.endianness)
635636
shape = self.get_shape(frame)
636637
offset = self._get_frame_offset(frame)
@@ -700,7 +701,7 @@ def __getitem__(self, sliceobj):
700701
"""
701702
sliceobj = canonical_slicers(sliceobj, self.shape)
702703
# Indices into sliceobj referring to image axes
703-
ax_inds = [i for i, obj in enumerate(sliceobj) if not obj is None]
704+
ax_inds = [i for i, obj in enumerate(sliceobj) if obj is not None]
704705
assert len(ax_inds) == len(self.shape)
705706
frame_mapping = get_frame_order(self._subheader._mlist)
706707
# Analyze index for 4th axis
@@ -786,7 +787,7 @@ def __init__(self, dataobj, affine, header,
786787
self._subheader = subheader
787788
self._mlist = mlist
788789
self._dataobj = dataobj
789-
if not affine is None:
790+
if affine is not None:
790791
# Check that affine is array-like 4,4. Maybe this is too strict at
791792
# this abstract level, but so far I think all image formats we know
792793
# do need 4,4.
@@ -863,7 +864,8 @@ def _get_fileholders(file_map):
863864
@classmethod
864865
def from_file_map(klass, file_map):
865866
"""class method to create image from mapping
866-
specified in file_map"""
867+
specified in file_map
868+
"""
867869
hdr_file, img_file = klass._get_fileholders(file_map)
868870
# note header and image are in same file
869871
hdr_fid = hdr_file.get_prepare_fileobj(mode='rb')

nibabel/fileslice.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def canonical_slicers(sliceobj, shape, check_inds=True):
9292
if Ellipsis in remaining:
9393
raise ValueError("More than one Ellipsis in slicing "
9494
"expression")
95-
real_remaining = [r for r in remaining if not r is None]
95+
real_remaining = [r for r in remaining if r is not None]
9696
n_ellided = n_dim - n_real - len(real_remaining)
9797
can_slicers.extend((slice(None),) * n_ellided)
9898
n_real += n_ellided
@@ -144,7 +144,7 @@ def slice2outax(ndim, sliceobj):
144144
if isinstance(obj, Integral):
145145
out_ax_inds.append(None)
146146
continue
147-
if not obj is None:
147+
if obj is not None:
148148
out_ax_inds.append(out_ax_no)
149149
out_ax_no += 1
150150
return tuple(out_ax_inds)
@@ -210,9 +210,9 @@ def fill_slicer(slicer, in_len):
210210
start, stop, step = slicer.start, slicer.stop, slicer.step
211211
if step is None:
212212
step = 1
213-
if not start is None and start < 0:
213+
if start is not None and start < 0:
214214
start = in_len + start
215-
if not stop is None and stop < 0:
215+
if stop is not None and stop < 0:
216216
stop = in_len + stop
217217
if step > 0:
218218
if start is None:
@@ -424,7 +424,7 @@ def optimize_slicer(slicer, dim_len, all_full, is_slowest, stride,
424424
elif action == 'contiguous': # Cannot be int
425425
# If this is already contiguous, default None behavior handles it
426426
step = slicer.step
427-
if not step in (-1, 1):
427+
if step not in (-1, 1):
428428
if step < 0:
429429
slicer = _positive_slice(slicer)
430430
return (slice(slicer.start, slicer.stop, 1),
@@ -480,7 +480,7 @@ def calc_slicedefs(sliceobj, in_shape, itemsize, offset, order,
480480
`segments` and reshaping via `read_shape`. Slices are in terms of
481481
`read_shape`. If empty, no new slicing to apply
482482
"""
483-
if not order in "CF":
483+
if order not in "CF":
484484
raise ValueError("order should be one of 'CF'")
485485
sliceobj = canonical_slicers(sliceobj, in_shape)
486486
# order fastest changing first (record reordering)

nibabel/freesurfer/mghformat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def from_file_map(klass, file_map, mmap=True):
492492
image data file cannot be memory-mapped, ignore `mmap` value and
493493
read array from file.
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
img_fh = file_map['image']
498498
mghf = img_fh.get_prepare_fileobj('rb')
@@ -528,7 +528,7 @@ def from_filename(klass, filename, mmap=True):
528528
-------
529529
img : MGHImage instance
530530
'''
531-
if not mmap in (True, False, 'c', 'r'):
531+
if mmap not in (True, False, 'c', 'r'):
532532
raise ValueError("mmap should be one of {True, False, 'c', 'r'}")
533533
file_map = klass.filespec_to_file_map(filename)
534534
return klass.from_file_map(file_map, mmap=mmap)

nibabel/info.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
_version_minor = 1
1212
_version_micro = 0
1313
_version_extra = 'dev'
14-
#_version_extra = ''
14+
# _version_extra = ''
1515

1616
# Format expected by setup.py and doc/source/conf.py: string of form "X.Y.Z"
1717
__version__ = "%s.%s.%s%s" % (_version_major,
@@ -109,8 +109,7 @@
109109

110110
# Main setup parameters
111111
NAME = 'nibabel'
112-
MAINTAINER = "Matthew Brett, Michael Hanke, Eric Larson, " \
113-
"Chris Markiewicz"
112+
MAINTAINER = "Matthew Brett, Michael Hanke, Eric Larson, Chris Markiewicz"
114113
MAINTAINER_EMAIL = "neuroimaging@python.org"
115114
DESCRIPTION = description
116115
LONG_DESCRIPTION = long_description

nibabel/minc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
FutureWarning,
88
stacklevel=2)
99

10-
from .minc1 import *
10+
from .minc1 import * # noqa

nibabel/minc1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def _normalize(self, data, sliceobj=()):
199199
shape = self.get_data_shape()
200200
sliceobj = canonical_slicers(sliceobj, shape)
201201
# Indices into sliceobj referring to image axes
202-
ax_inds = [i for i, obj in enumerate(sliceobj) if not obj is None]
202+
ax_inds = [i for i, obj in enumerate(sliceobj) if obj is not None]
203203
assert len(ax_inds) == len(shape)
204204
# Slice imax, imin using same slicer as for data
205205
nscales_ax = ax_inds[nscales]

0 commit comments

Comments
 (0)