Add unit test to catch non-integer output shape bug

This commit is contained in:
Stefan van der Walt
2014-05-02 16:23:41 +02:00
parent 00b4fa45e7
commit 4c7cd9bd65
2 changed files with 11 additions and 5 deletions
+6 -5
View File
@@ -1074,7 +1074,12 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
image = np.atleast_3d(img_as_float(image))
ishape = np.array(image.shape)
bands = ishape[2]
output_shape = np.array(output_shape, dtype=int)
if output_shape is None:
output_shape = ishape
else:
output_shape = np.array(output_shape, dtype=int)
out = None
@@ -1111,10 +1116,6 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
out = out[..., 0]
if out is None: # use ndimage.map_coordinates
if output_shape is None:
output_shape = ishape
rows, cols = output_shape[:2]
# inverse_map is a transformation matrix as numpy array
+5
View File
@@ -248,5 +248,10 @@ def test_inverse():
assert_array_equal(warp(image, inverse_tform), warp(image, tform.inverse))
def test_slow_warp_nonint_oshape():
image = np.random.random((5, 5))
warp(image, lambda xy: xy, output_shape=(13.1, 19.5))
if __name__ == "__main__":
run_module_suite()