mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-28 21:47:10 +08:00
Add test case for invalid image dimensions
This commit is contained in:
@@ -1025,8 +1025,8 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
|
||||
'the `inverse_map` parameter.')
|
||||
inverse_map = reverse_map
|
||||
|
||||
if image.ndim < 2:
|
||||
raise ValueError("Input must have more than 1 dimension.")
|
||||
if image.ndim < 2 or image.ndim > 3:
|
||||
raise ValueError("Input must have 2 or 3 dimensions.")
|
||||
|
||||
orig_ndim = image.ndim
|
||||
image = np.atleast_3d(img_as_float(image))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from numpy.testing import assert_array_almost_equal, run_module_suite, assert_array_equal
|
||||
from numpy.testing import (assert_array_almost_equal, run_module_suite,
|
||||
assert_array_equal, assert_raises)
|
||||
import numpy as np
|
||||
from scipy.ndimage import map_coordinates
|
||||
|
||||
@@ -234,5 +235,10 @@ def test_downscale_local_mean():
|
||||
assert_array_equal(expected2, out2)
|
||||
|
||||
|
||||
def test_invalid():
|
||||
assert_raises(ValueError, warp, np.ones((4, )), SimilarityTransform())
|
||||
assert_raises(ValueError, warp, np.ones((4, 3, 3, 3)), SimilarityTransform())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user