Skip to content

Commit 3303a52

Browse files
committed
RF: Drop code explicitly tagged as PY2
1 parent 66ed14e commit 3303a52

File tree

5 files changed

+3
-36
lines changed

5 files changed

+3
-36
lines changed

nibabel/cifti2/cifti2.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
http://www.nitrc.org/projects/cifti
1818
'''
1919
import re
20-
try:
21-
from collections.abc import MutableSequence, MutableMapping, Iterable
22-
except ImportError:
23-
# PY2 compatibility
24-
from collections import MutableSequence, MutableMapping, Iterable
20+
from collections.abc import MutableSequence, MutableMapping, Iterable
2521
from collections import OrderedDict
2622
from .. import xmlutils as xml
2723
from ..filebasedimages import FileBasedHeader

nibabel/externals/oset.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
"""
1515

1616

17-
try:
18-
from collections.abc import MutableSet
19-
except ImportError:
20-
# PY2 compatibility
21-
from collections import MutableSet
17+
from collections.abc import MutableSet
2218

2319
KEY, PREV, NEXT = range(3)
2420

nibabel/streamlines/tractogram.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
import numbers
33
import numpy as np
44
from warnings import warn
5-
6-
try:
7-
from collections.abc import MutableMapping
8-
except ImportError:
9-
# PY2 compatibility
10-
from collections import MutableMapping
5+
from collections.abc import MutableMapping
116

127
from nibabel.affines import apply_affine
138

nibabel/tests/test_fileslice.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import sys
44

5-
PY2 = sys.version_info[0] < 3
6-
75
from io import BytesIO
86
from itertools import product
97
from functools import partial
@@ -250,9 +248,6 @@ def test_threshold_heuristic():
250248
assert_equal(threshold_heuristic(1, 9, 1, skip_thresh=7), None)
251249
assert_equal(threshold_heuristic(1, 9, 2, skip_thresh=16), 'full')
252250
assert_equal(threshold_heuristic(1, 9, 2, skip_thresh=15), None)
253-
# long if on Python 2
254-
if PY2:
255-
assert_equal(threshold_heuristic(long(1), 9, 1, skip_thresh=8), 'full')
256251
# full slice, smallest step size
257252
assert_equal(threshold_heuristic(
258253
slice(0, 9, 1), 9, 2, skip_thresh=2),
@@ -515,10 +510,6 @@ def test_optimize_read_slicers():
515510
assert_equal(optimize_read_slicers(
516511
(1, 2, 3), (2, 3, 4), 4, _always),
517512
((sn, sn, 3), (1, 2)))
518-
if PY2: # Check we can pass in longs as well
519-
assert_equal(optimize_read_slicers(
520-
(long(1), long(2), long(3)), (2, 3, 4), 4, _always),
521-
((sn, sn, 3), (1, 2)))
522513

523514

524515
def test_slicers2segments():
@@ -540,10 +531,6 @@ def test_slicers2segments():
540531
assert_equal(slicers2segments(
541532
(slice(None), slice(None), 2), (10, 6, 4), 7, 4),
542533
[[7 + 10 * 6 * 2 * 4, 10 * 6 * 4]])
543-
if PY2: # Check we can pass longs on Python 2
544-
assert_equal(
545-
slicers2segments((long(0), long(1), long(2)), (10, 6, 4), 7, 4),
546-
[[7 + 10 * 4 + 10 * 6 * 2 * 4, 4]])
547534

548535

549536
def test_calc_slicedefs():

nibabel/tests/test_floating.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"""
33
import sys
44

5-
PY2 = sys.version_info[0] < 3
6-
75
from distutils.version import LooseVersion
86

97
import numpy as np
@@ -186,11 +184,6 @@ def test_int_to_float():
186184
i = 2**(nmant + 1) - 1
187185
assert_equal(as_int(int_to_float(i, LD)), i)
188186
assert_equal(as_int(int_to_float(-i, LD)), -i)
189-
# Test no error for longs
190-
if PY2:
191-
i = long(i)
192-
assert_equal(as_int(int_to_float(i, LD)), i)
193-
assert_equal(as_int(int_to_float(-i, LD)), -i)
194187
# If longdouble can cope with 2**64, test
195188
if nmant >= 63:
196189
# Check conversion to int; the line below causes an error subtracting

0 commit comments

Comments
 (0)