Skip to content

Commit c42fb22

Browse files
committed
PEP8/PyFlakes cleanup of nibabel/*/ excluding tests (tests pass)
1 parent 77b68f5 commit c42fb22

19 files changed

+175
-164
lines changed

nibabel/benchmarks/bench_array_to_file.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
nib.bench()
77
88
If you have doctests enabled by default in nose (with a noserc file or
9-
environment variable), and you have a numpy version <= 1.6.1, this will also run
10-
the doctests, let's hope they pass.
9+
environment variable), and you have a numpy version <= 1.6.1, this will also
10+
run the doctests, let's hope they pass.
1111
1212
Run this benchmark with:
1313
@@ -26,6 +26,7 @@
2626

2727
from numpy.testing import measure
2828

29+
2930
def bench_array_to_file():
3031
rng = np.random.RandomState(20111001)
3132
repeat = 10

nibabel/benchmarks/bench_fileslice.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
nib.bench()
55
66
If you have doctests enabled by default in nose (with a noserc file or
7-
environment variable), and you have a numpy version <= 1.6.1, this will also run
8-
the doctests, let's hope they pass.
7+
environment variable), and you have a numpy version <= 1.6.1, this will also
8+
run the doctests, let's hope they pass.
99
1010
Run this benchmark with:
1111
@@ -55,6 +55,7 @@ def run_slices(file_like, repeat=3, offset=0, order='F'):
5555
for j, slicer in enumerate(_slices_for_len(L)):
5656
sliceobj = [slice(None)] * n_dim
5757
sliceobj[i] = slicer
58+
5859
def f():
5960
fileslice(fobj,
6061
tuple(sliceobj),
@@ -63,10 +64,11 @@ def f():
6364
offset,
6465
order)
6566
times_arr[i, j] = timeit(f, number=repeat)
67+
6668
def g():
6769
fobj.seek(offset)
6870
data = fobj.read()
69-
_ = np.ndarray(SHAPE, arr.dtype, buffer=data, order=order)
71+
np.ndarray(SHAPE, arr.dtype, buffer=data, order=order)
7072
base_time = timeit(g, number=repeat)
7173
return times_arr, base_time
7274

@@ -77,33 +79,34 @@ def bench_fileslice(bytes=True,
7779
bz2=False):
7880
sys.stdout.flush()
7981
repeat = 2
82+
8083
def my_table(title, times, base):
8184
print()
8285
print(rst_table(times, ROW_NAMES, COL_NAMES, title,
83-
val_fmt='{0[0]:3.2f} ({0[1]:3.2f})'))
86+
val_fmt='{0[0]:3.2f} ({0[1]:3.2f})'))
8487
print('Base time: {0:3.2f}'.format(base))
8588
if bytes:
8689
fobj = BytesIO()
8790
times, base = run_slices(fobj, repeat)
8891
my_table('Bytes slice - raw (ratio)',
89-
np.dstack((times, times / base)),
90-
base)
92+
np.dstack((times, times / base)),
93+
base)
9194
if file_:
9295
with InTemporaryDirectory():
9396
file_times, file_base = run_slices('data.bin', repeat)
9497
my_table('File slice - raw (ratio)',
95-
np.dstack((file_times, file_times / file_base)),
96-
file_base)
98+
np.dstack((file_times, file_times / file_base)),
99+
file_base)
97100
if gz:
98101
with InTemporaryDirectory():
99102
gz_times, gz_base = run_slices('data.gz', repeat)
100103
my_table('gz slice - raw (ratio)',
101-
np.dstack((gz_times, gz_times / gz_base)),
102-
gz_base)
104+
np.dstack((gz_times, gz_times / gz_base)),
105+
gz_base)
103106
if bz2:
104107
with InTemporaryDirectory():
105108
bz2_times, bz2_base = run_slices('data.bz2', repeat)
106109
my_table('bz2 slice - raw (ratio)',
107-
np.dstack((bz2_times, bz2_times / bz2_base)),
108-
bz2_base)
110+
np.dstack((bz2_times, bz2_times / bz2_base)),
111+
bz2_base)
109112
sys.stdout.flush()

nibabel/benchmarks/bench_finite_range.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
nib.bench()
77
88
If you have doctests enabled by default in nose (with a noserc file or
9-
environment variable), and you have a numpy version <= 1.6.1, this will also run
10-
the doctests, let's hope they pass.
9+
environment variable), and you have a numpy version <= 1.6.1, this will also
10+
run the doctests, let's hope they pass.
1111
1212
Run this benchmark with:
1313
@@ -26,6 +26,7 @@
2626

2727
from numpy.testing import measure
2828

29+
2930
def bench_finite_range():
3031
rng = np.random.RandomState(20111001)
3132
repeat = 10

nibabel/benchmarks/bench_load_save.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
nib.bench()
77
88
If you have doctests enabled by default in nose (with a noserc file or
9-
environment variable), and you have a numpy version <= 1.6.1, this will also run
10-
the doctests, let's hope they pass.
9+
environment variable), and you have a numpy version <= 1.6.1, this will also
10+
run the doctests, let's hope they pass.
1111
1212
Run this benchmark with:
1313
@@ -27,6 +27,7 @@
2727

2828
from numpy.testing import measure
2929

30+
3031
def bench_load_save():
3132
rng = np.random.RandomState(20111001)
3233
repeat = 10

nibabel/benchmarks/butils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from .. import get_info
66

7+
78
def print_git_title(title):
89
""" Prints title string with git hash if possible, and underline
910
"""

nibabel/externals/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# init for externals package
22
try:
33
from collections import OrderedDict
4-
except ImportError: # < Python 2.7
4+
except ImportError: # < Python 2.7
55
from .ordereddict import OrderedDict

nibabel/freesurfer/mghformat.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __init__(self,
105105
hdr = np.ndarray(shape=(),
106106
dtype=self.template_dtype,
107107
buffer=binaryblock)
108-
#if goodRASFlag, discard delta, Mdc and c_ras stuff
108+
# if goodRASFlag, discard delta, Mdc and c_ras stuff
109109
if int(hdr['goodRASFlag']) < 0:
110110
hdr = self._set_affine_default(hdr)
111111
self._header_data = hdr.copy()
@@ -179,15 +179,14 @@ def from_fileobj(klass, fileobj, check=True):
179179
# dimensions from the header, skip over and then read the footer
180180
# information
181181
hdr_str = fileobj.read(klass._hdrdtype.itemsize)
182-
hdr_str_to_np = np.ndarray(shape=(),
183-
dtype=klass._hdrdtype,
184-
buffer=hdr_str)
182+
hdr_str_to_np = np.ndarray(shape=(), dtype=klass._hdrdtype,
183+
buffer=hdr_str)
185184
if not np.all(hdr_str_to_np['dims']):
186185
raise MGHError('Dimensions of the data should be non-zero')
187186
tp = int(hdr_str_to_np['type'])
188-
fileobj.seek(DATA_OFFSET + \
189-
int(klass._data_type_codes.bytespervox[tp]) * \
190-
np.prod(hdr_str_to_np['dims']))
187+
fileobj.seek(DATA_OFFSET +
188+
int(klass._data_type_codes.bytespervox[tp]) *
189+
np.prod(hdr_str_to_np['dims']))
191190
ftr_str = fileobj.read(klass._ftrdtype.itemsize)
192191
return klass(hdr_str + ftr_str, check)
193192

@@ -344,7 +343,7 @@ def set_data_shape(self, shape):
344343
def get_data_bytespervox(self):
345344
''' Get the number of bytes per voxel of the data
346345
'''
347-
return int(self._data_type_codes.bytespervox[ \
346+
return int(self._data_type_codes.bytespervox[
348347
int(self._header_data['type'])])
349348

350349
def get_data_size(self):
@@ -483,10 +482,10 @@ def from_file_map(klass, file_map, mmap=True):
483482
mmap : {True, False, 'c', 'r'}, optional, keyword only
484483
`mmap` controls the use of numpy memory mapping for reading image
485484
array data. If False, do not try numpy ``memmap`` for data array.
486-
If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A `mmap`
487-
value of True gives the same behavior as ``mmap='c'``. If image
488-
data file cannot be memory-mapped, ignore `mmap` value and read
489-
array from file.
485+
If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A
486+
`mmap` value of True gives the same behavior as ``mmap='c'``. If
487+
image data file cannot be memory-mapped, ignore `mmap` value and
488+
read array from file.
490489
'''
491490
if not mmap in (True, False, 'c', 'r'):
492491
raise ValueError("mmap should be one of {True, False, 'c', 'r'}")
@@ -513,10 +512,10 @@ def from_filename(klass, filename, mmap=True):
513512
mmap : {True, False, 'c', 'r'}, optional, keyword only
514513
`mmap` controls the use of numpy memory mapping for reading image
515514
array data. If False, do not try numpy ``memmap`` for data array.
516-
If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A `mmap`
517-
value of True gives the same behavior as ``mmap='c'``. If image
518-
data file cannot be memory-mapped, ignore `mmap` value and read
519-
array from file.
515+
If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A
516+
`mmap` value of True gives the same behavior as ``mmap='c'``. If
517+
image data file cannot be memory-mapped, ignore `mmap` value and
518+
read array from file.
520519
521520
Returns
522521
-------

nibabel/gifti/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@
2020
from .giftiio import read, write
2121
from .gifti import (GiftiMetaData, GiftiNVPairs, GiftiLabelTable, GiftiLabel,
2222
GiftiCoordSystem, data_tag, GiftiDataArray, GiftiImage)
23-

0 commit comments

Comments
 (0)