Adjust tests for new type conversion rules

This commit is contained in:
cgohlke
2012-05-22 00:25:42 -07:00
parent 3ff1ebf526
commit e4b49239c4
+4 -11
View File
@@ -9,8 +9,8 @@ dtype_range = {np.uint8: (0, 255),
np.uint16: (0, 65535),
np.int8: (-128, 127),
np.int16: (-32768, 32767),
np.float32: (0, 1),
np.float64: (0, 1)}
np.float32: (-1.0, 1.0),
np.float64: (-1.0, 1.0)}
def _verify_range(msg, x, vmin, vmax):
assert_equal(x[0], vmin)
@@ -29,8 +29,9 @@ def test_range():
omin, omax = dtype_range[dt]
if imin == 0:
if imin == 0 or omin == 0:
omin = 0
imin = 0
yield _verify_range, \
"From %s to %s" % (np.dtype(dtype), np.dtype(dt)), \
@@ -67,13 +68,6 @@ def test_unsupported_dtype():
assert_raises(ValueError, img_as_int, x)
def test_float_out_of_range():
too_high = np.array([2], dtype=np.float32)
assert_raises(ValueError, img_as_int, too_high)
too_low = np.array([-1], dtype=np.float32)
assert_raises(ValueError, img_as_int, too_low)
def test_copy():
x = np.array([1], dtype=np.float64)
y = img_as_float(x)
@@ -84,4 +78,3 @@ def test_copy():
if __name__ == '__main__':
np.testing.run_module_suite()