Skip to content

Commit 17c9dc2

Browse files
committed
MNT: All supported numpy have float16
1 parent a36b1c7 commit 17c9dc2

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

nibabel/casting.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,6 @@ def shared_range(flt_type, int_type):
171171
# types.
172172
# ----------------------------------------------------------------------------
173173

174-
try:
175-
_float16 = np.float16
176-
except AttributeError: # float16 not present in np < 1.6
177-
_float16 = None
178-
179-
180174
class FloatingError(Exception):
181175
pass
182176

@@ -242,7 +236,7 @@ def type_info(np_type):
242236
minexp=info.minexp,
243237
maxexp=info.maxexp,
244238
width=width)
245-
if np_type in (_float16, np.float32, np.float64,
239+
if np_type in (np.float16, np.float32, np.float64,
246240
np.complex64, np.complex128):
247241
return ret
248242
info_64 = np.finfo(np.float64)

nibabel/tests/test_floating.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@
1515
from nose import SkipTest
1616
from nose.tools import assert_equal, assert_raises, assert_true, assert_false
1717

18-
IEEE_floats = [np.float32, np.float64]
19-
try:
20-
np.float16
21-
except AttributeError: # float16 not present in np < 1.6
22-
have_float16 = False
23-
else:
24-
have_float16 = True
25-
if have_float16:
26-
IEEE_floats.append(np.float16)
18+
IEEE_floats = [np.float16, np.float32, np.float64]
2719

2820
LD_INFO = type_info(np.longdouble)
2921

@@ -201,8 +193,6 @@ def test_as_int_np_fix():
201193

202194
def test_floor_exact_16():
203195
# A normal integer can generate an inf in float16
204-
if not have_float16:
205-
raise SkipTest('No float16')
206196
assert_equal(floor_exact(2**31, np.float16), np.inf)
207197
assert_equal(floor_exact(-2**31, np.float16), -np.inf)
208198

0 commit comments

Comments
 (0)