Skip to content

Commit 931ed53

Browse files
committed
TEST: Revise equality check to approximate
get_fdata(dtype=float32) and get_fdata(dtype=float64).astype(float32) are no longer equivalent
1 parent dfebe58 commit 931ed53

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

nibabel/tests/test_image_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,18 @@ def _check_proxy_interface(self, imaker, meth_name):
314314
# New data dtype, no caching, doesn't use or alter cache
315315
fdata_new_dt = img.get_fdata(caching='unchanged', dtype='f4')
316316
# We get back the original read, not the modified cache
317-
assert_array_equal(fdata_new_dt, proxy_data.astype('f4'))
317+
assert_almost_equal(fdata_new_dt, proxy_data.astype('f4'))
318318
assert_equal(fdata_new_dt.dtype, np.float32)
319319
# The original cache stays in place, for default float64
320320
assert_array_equal(img.get_fdata(), 42)
321321
# And for not-default float32, because we haven't cached
322322
fdata_new_dt[:] = 43
323323
fdata_new_dt = img.get_fdata(caching='unchanged', dtype='f4')
324-
assert_array_equal(fdata_new_dt, proxy_data.astype('f4'))
324+
assert_almost_equal(fdata_new_dt, proxy_data.astype('f4'))
325325
# Until we reset with caching='fill', at which point we
326326
# drop the original float64 cache, and have a float32 cache
327327
fdata_new_dt = img.get_fdata(caching='fill', dtype='f4')
328-
assert_array_equal(fdata_new_dt, proxy_data.astype('f4'))
328+
assert_almost_equal(fdata_new_dt, proxy_data.astype('f4'))
329329
# We're using the cache, for dtype='f4' reads
330330
fdata_new_dt[:] = 43
331331
assert_array_equal(img.get_fdata(dtype='f4'), 43)

0 commit comments

Comments
 (0)