Skip to content

Commit ac52ad8

Browse files
committed
TEST: Validate get_scaled with several float types
1 parent 5577eb8 commit ac52ad8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

nibabel/tests/test_proxy_api.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
from nose import SkipTest
5454
from nose.tools import (assert_true, assert_false, assert_raises,
55-
assert_equal, assert_not_equal)
55+
assert_equal, assert_not_equal, assert_greater_equal)
5656

5757
from numpy.testing import (assert_almost_equal, assert_array_equal)
5858

@@ -131,6 +131,22 @@ def validate_asarray(self, pmaker, params):
131131
# Shape matches expected shape
132132
assert_equal(out.shape, params['shape'])
133133

134+
def validate_get_scaled(self, pmaker, params):
135+
# Check proxy returns expected array from asarray
136+
prox, fio, hdr = pmaker()
137+
out = prox.get_scaled()
138+
assert_array_equal(out, params['arr_out'])
139+
assert_dt_equal(out.dtype, params['dtype_out'])
140+
# Shape matches expected shape
141+
assert_equal(out.shape, params['shape'])
142+
143+
for dtype in (np.float16, np.float32, np.float64, np.float128):
144+
out = prox.get_scaled(dtype=dtype)
145+
assert_almost_equal(out, params['arr_out'])
146+
assert_greater_equal(out.dtype, np.dtype(dtype))
147+
# Shape matches expected shape
148+
assert_equal(out.shape, params['shape'])
149+
134150
def validate_header_isolated(self, pmaker, params):
135151
# Confirm altering input header has no effect
136152
# Depends on header providing 'get_data_dtype', 'set_data_dtype',

0 commit comments

Comments
 (0)