Skip to content

Commit e87d581

Browse files
committed
BF: another workaround for elderly numpy 1.7.1
1 parent e4c5b52 commit e87d581

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

nibabel/cmdline/diff.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ def are_values_different(*values):
5757
# to not recompute over again
5858
if isinstance(value0, np.ndarray):
5959
try:
60-
value0_nans = np.isnan(value0)
60+
# np.asarray for elderly numpys, e.g. 1.7.1 where for
61+
# degenerate arrays (shape ()) it would return a pure scalar
62+
value0_nans = np.asanyarray(np.isnan(value0))
63+
value0_nonnans = np.asanyarray(np.logical_not(value0_nans))
64+
# if value0_nans.size == 1:
65+
# import pdb; pdb.set_trace()
6166
if not np.any(value0_nans):
6267
value0_nans = None
6368
except TypeError as exc:
@@ -80,8 +85,7 @@ def are_values_different(*values):
8085
value_nans = np.isnan(value)
8186
if np.any(value0_nans != value_nans):
8287
return True
83-
if np.any(value0[np.logical_not(value0_nans)]
84-
!= value[np.logical_not(value0_nans)]):
88+
if np.any(value0[value0_nonnans] != value[value0_nonnans]):
8589
return True
8690
elif np.any(value0 != value):
8791
return True

0 commit comments

Comments
 (0)