Skip to content

Commit d071381

Browse files
committed
BF: fix dependency on numpy >= 1.8 in viewer
Viewer was using `np.take` with integer argument for `indices`, only allowed in numpy 1.8 or greater. Instead, use rollaxis and slicing to get the slice that we need. This should also be faster, because we always get a view rather than a copy.
1 parent f9614fe commit d071381

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ matrix:
3737
- python: 2.7
3838
env:
3939
- DEPENDS=numpy==1.5.1 PYDICOM=0
40+
# Absolute minimum dependencies plus oldest MPL
41+
- python: 2.7
42+
env:
43+
- DEPENDS=numpy==1.5.1 matplotlib==1.3.1 PYDICOM=0
4044
# Minimum pydicom dependency
4145
- python: 2.7
4246
env:

nibabel/viewers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ def _set_position(self, x, y, z, notify=True):
382382
# sagittal: get to S/A
383383
# coronal: get to S/L
384384
# axial: get to A/L
385-
data = np.take(self._current_vol_data, self._data_idx[ii],
386-
axis=self._order[ii])
385+
data = np.rollaxis(self._current_vol_data,
386+
axis=self._order[ii])[self._data_idx[ii]]
387387
xax = [1, 0, 0][ii]
388388
yax = [2, 2, 1][ii]
389389
if self._order[xax] < self._order[yax]:

0 commit comments

Comments
 (0)