Skip to content

Commit a6fa121

Browse files
committed
RF: Purge six
1 parent 9d5ab96 commit a6fa121

31 files changed

+43
-148
lines changed

COPYING

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -218,34 +218,3 @@ the PDDL version 1.0 available at http://opendatacommons.org/licenses/pddl/1.0/
218218

219219
is courtesy of the University of Massachusetts Medical School, also released
220220
under the PDDL.
221-
222-
223-
Six
224-
--------------------
225-
226-
In ``nibabel/externals/six.py``
227-
228-
Copied from: https://pypi.python.org/packages/source/s/six/six-1.3.0.tar.gz#md5=ec47fe6070a8a64c802363d2c2b1e2ee
229-
230-
::
231-
232-
Copyright (c) 2010-2013 Benjamin Peterson
233-
234-
Permission is hereby granted, free of charge, to any person obtaining a copy of
235-
this software and associated documentation files (the "Software"), to deal in
236-
the Software without restriction, including without limitation the rights to
237-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
238-
the Software, and to permit persons to whom the Software is furnished to do so,
239-
subject to the following conditions:
240-
241-
The above copyright notice and this permission notice shall be included in all
242-
copies or substantial portions of the Software.
243-
244-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
245-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
246-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
247-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
248-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
249-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
250-
251-

nibabel/affines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77

8-
from six.moves import reduce
8+
from functools import reduce
99

1010

1111
class AffineError(ValueError):

nibabel/benchmarks/bench_streamlines.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import numpy as np
1919

20-
from six.moves import zip
2120
from nibabel.tmpdirs import InTemporaryDirectory
2221

2322
from numpy.testing import assert_array_equal

nibabel/brikhead.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import re
3535

3636
import numpy as np
37-
from six import string_types
3837

3938
from .arrayproxy import ArrayProxy
4039
from .fileslice import strided_scalar
@@ -204,7 +203,7 @@ def parse_AFNI_header(fobj):
204203
[1, 1, 1]
205204
"""
206205
# edge case for being fed a filename instead of a file object
207-
if isinstance(fobj, string_types):
206+
if isinstance(fobj, str):
208207
with open(fobj, 'rt') as src:
209208
return parse_AFNI_header(src)
210209
# unpack variables in HEAD file

nibabel/cifti2/cifti2_axes.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
"""
121121
import numpy as np
122122
from . import cifti2
123-
from six import string_types, add_metaclass, integer_types
124123
from operator import xor
125124
import abc
126125

@@ -173,8 +172,7 @@ def to_header(axes):
173172
return cifti2.Cifti2Header(matrix)
174173

175174

176-
@add_metaclass(abc.ABCMeta)
177-
class Axis(object):
175+
class Axis(object, metaclass=abc.ABCMeta):
178176
"""
179177
Abstract class for any object describing the rows or columns of a CIFTI-2 vector/matrix
180178
@@ -289,7 +287,7 @@ def __init__(self, name, voxel=None, vertex=None, affine=None,
289287
else:
290288
self.vertex = np.asanyarray(vertex, dtype=int)
291289

292-
if isinstance(name, string_types):
290+
if isinstance(name, str):
293291
name = [self.to_cifti_brain_structure_name(name)] * self.vertex.size
294292
self.name = np.asanyarray(name, dtype='U')
295293

@@ -505,7 +503,7 @@ def to_cifti_brain_structure_name(name):
505503
"""
506504
if name in cifti2.CIFTI_BRAIN_STRUCTURES:
507505
return name
508-
if not isinstance(name, string_types):
506+
if not isinstance(name, str):
509507
if len(name) == 1:
510508
structure = name[0]
511509
orientation = 'both'
@@ -589,7 +587,7 @@ def volume_shape(self, value):
589587
value = tuple(value)
590588
if len(value) != 3:
591589
raise ValueError("Volume shape should be a tuple of length 3")
592-
if not all(isinstance(v, integer_types) for v in value):
590+
if not all(isinstance(v, int) for v in value):
593591
raise ValueError("All elements of the volume shape should be integers")
594592
self._volume_shape = value
595593

@@ -679,9 +677,9 @@ def __getitem__(self, item):
679677
680678
Otherwise returns a new BrainModelAxis
681679
"""
682-
if isinstance(item, integer_types):
680+
if isinstance(item, int):
683681
return self.get_element(item)
684-
if isinstance(item, string_types):
682+
if isinstance(item, str):
685683
raise IndexError("Can not index an Axis with a string (except for ParcelsAxis)")
686684
return self.__class__(self.name[item], self.voxel[item], self.vertex[item],
687685
self.affine, self.volume_shape, self.nvertices)
@@ -914,7 +912,7 @@ def volume_shape(self, value):
914912
value = tuple(value)
915913
if len(value) != 3:
916914
raise ValueError("Volume shape should be a tuple of length 3")
917-
if not all(isinstance(v, integer_types) for v in value):
915+
if not all(isinstance(v, int) for v in value):
918916
raise ValueError("All elements of the volume shape should be integers")
919917
self._volume_shape = value
920918

@@ -989,14 +987,14 @@ def __getitem__(self, item):
989987
- `string`: 2-element tuple of (parcel voxels, parcel vertices
990988
- other object that can index 1D arrays: new Parcel axis
991989
"""
992-
if isinstance(item, string_types):
990+
if isinstance(item, str):
993991
idx = np.where(self.name == item)[0]
994992
if len(idx) == 0:
995993
raise IndexError("Parcel %s not found" % item)
996994
if len(idx) > 1:
997995
raise IndexError("Multiple parcels with name %s found" % item)
998996
return self.voxels[idx[0]], self.vertices[idx[0]]
999-
if isinstance(item, integer_types):
997+
if isinstance(item, int):
1000998
return self.get_element(item)
1001999
return self.__class__(self.name[item], self.voxels[item], self.vertices[item],
10021000
self.affine, self.volume_shape, self.nvertices)
@@ -1125,7 +1123,7 @@ def __add__(self, other):
11251123
)
11261124

11271125
def __getitem__(self, item):
1128-
if isinstance(item, integer_types):
1126+
if isinstance(item, int):
11291127
return self.get_element(item)
11301128
return self.__class__(self.name[item], self.meta[item])
11311129

@@ -1270,7 +1268,7 @@ def __add__(self, other):
12701268
)
12711269

12721270
def __getitem__(self, item):
1273-
if isinstance(item, integer_types):
1271+
if isinstance(item, int):
12741272
return self.get_element(item)
12751273
return self.__class__(self.name[item], self.label[item], self.meta[item])
12761274

@@ -1437,7 +1435,7 @@ def __getitem__(self, item):
14371435
nelements = 0
14381436
return SeriesAxis(idx_start * self.step + self.start, self.step * step,
14391437
nelements, self.unit)
1440-
elif isinstance(item, integer_types):
1438+
elif isinstance(item, int):
14411439
return self.get_element(item)
14421440
raise IndexError('SeriesAxis can only be indexed with integers or slices '
14431441
'without breaking the regular structure')

nibabel/cmdline/tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from os.path import (join as pjoin)
1616
from nibabel.testing import data_path
1717
from collections import OrderedDict
18-
from six import StringIO
18+
from io import StringIO
1919

2020

2121
def test_table2string():

nibabel/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from os.path import join as pjoin
99
import glob
1010
import sys
11-
from six.moves import configparser
11+
import configparser
1212
from distutils.version import LooseVersion
1313

1414
from .environment import get_nipy_user_dir, get_nipy_system_dir

nibabel/eulerangles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585

8686
import math
8787

88-
from six.moves import reduce
88+
from functools import reduce
8989

9090
import numpy as np
9191

nibabel/externals/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
# init for externals package
2-
from collections import OrderedDict
3-
4-
from ..deprecated import ModuleProxy as _ModuleProxy
5-
six = _ModuleProxy('nibabel.externals.six')

nibabel/externals/netcdf.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
from numpy import little_endian as LITTLE_ENDIAN
4242
from functools import reduce
4343

44-
from six import integer_types
45-
4644

4745
ABSENT = b'\x00\x00\x00\x00\x00\x00\x00\x00'
4846
ZERO = b'\x00\x00\x00\x00'
@@ -480,8 +478,8 @@ def _write_values(self, values):
480478
if hasattr(values, 'dtype'):
481479
nc_type = REVERSE[values.dtype.char, values.dtype.itemsize]
482480
else:
483-
types = [(t, NC_INT) for t in integer_types]
484-
types += [
481+
types = [
482+
(int, NC_INT),
485483
(float, NC_FLOAT),
486484
(str, NC_CHAR),
487485
]

0 commit comments

Comments
 (0)