Skip to content

Commit c6582ca

Browse files
committed
BF: remove uses of float indices; double ellipsis
Float indices becoming illegal in numpy 1.12. Also double ellipses.
1 parent 33f38c7 commit c6582ca

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

nibabel/nicom/dicomwrappers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
processing that needs to raise an error, should be in a method, rather
1212
than in a property, or property-like thing.
1313
"""
14+
from __future__ import division
1415

1516
import operator
1617

@@ -724,7 +725,7 @@ class MosaicWrapper(SiemensWrapper):
724725
Adds attributes:
725726
726727
* n_mosaic : int
727-
* mosaic_size : float
728+
* mosaic_size : int
728729
"""
729730
is_mosaic = True
730731

@@ -758,7 +759,7 @@ def __init__(self, dcm_data, csa_header=None, n_mosaic=None):
758759
'header; is this really '
759760
'Siemens mosiac data?')
760761
self.n_mosaic = n_mosaic
761-
self.mosaic_size = np.ceil(np.sqrt(n_mosaic))
762+
self.mosaic_size = int(np.ceil(np.sqrt(n_mosaic)))
762763

763764
@one_time
764765
def image_shape(self):

nibabel/orientations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ def inv_ornt_aff(ornt, shape):
220220
# ornt indicates the transpose that has occurred to get the current
221221
# ordering, relative to canonical, so we just use that.
222222
# undo_reorder is a row permutatation matrix
223-
undo_reorder = np.eye(p + 1)[list(ornt[:, 0]) + [p], :]
223+
axis_transpose = [int(v) for v in ornt[:, 0]]
224+
undo_reorder = np.eye(p + 1)[axis_transpose + [p], :]
224225
undo_flip = np.diag(list(ornt[:, 1]) + [1.0])
225226
center_trans = -(shape - 1) / 2.0
226227
undo_flip[:p, p] = (ornt[:, 1] * center_trans) - center_trans

nibabel/tests/test_fileslice.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
from io import BytesIO
88
from itertools import product
99
from functools import partial
10+
from distutils.version import LooseVersion
1011

1112
import numpy as np
1213

14+
# np > 1.11 makes double ellipsis illegal in indices
15+
HAVE_NP_GT_1p11 = LooseVersion(np.__version__) > '1.11'
16+
1317
from ..fileslice import (is_fancy, canonical_slicers, fileslice,
1418
predict_shape, read_segments, _positive_slice,
1519
threshold_heuristic, optimize_slicer, slice2len,
@@ -41,7 +45,11 @@ def test_is_fancy():
4145
for slice0 in slices:
4246
_check_slice(slice0)
4347
_check_slice((slice0,)) # tuple is same
48+
# Double ellipsis illegal in np 1.12dev - set up check for that case
49+
maybe_bad = HAVE_NP_GT_1p11 and slice0 is Ellipsis
4450
for slice1 in slices:
51+
if maybe_bad and slice1 is Ellipsis:
52+
continue
4553
_check_slice((slice0, slice1))
4654
assert_false(is_fancy((None,)))
4755
assert_false(is_fancy((None, 1)))

0 commit comments

Comments
 (0)