Skip to content

Commit f545e33

Browse files
author
Robert D. Vincent
committed
BF: Correctly use data type's inherent range if the valid_range attribute is missing.
1 parent 1c4ac28 commit f545e33

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

nibabel/minc1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _get_valid_range(self):
134134
try:
135135
valid_range = [self._image.valid_min,
136136
self._image.valid_max]
137-
except AttributeError:
137+
except (AttributeError, KeyError):
138138
valid_range = [info.min, info.max]
139139
if valid_range[0] < info.min or valid_range[1] > info.max:
140140
raise ValueError('Valid range outside input '

nibabel/minc2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _get_valid_range(self):
9595
info = np.iinfo(ddt.type)
9696
try:
9797
valid_range = self._image.attrs['valid_range']
98-
except AttributeError:
98+
except (AttributeError, KeyError):
9999
valid_range = [info.min, info.max]
100100
else:
101101
if valid_range[0] < info.min or valid_range[1] > info.max:

0 commit comments

Comments
 (0)