Add tests for wrong input shapes

This commit is contained in:
Johannes Schönberger
2013-12-09 00:44:36 +01:00
parent baa0b2cfbf
commit 7924c46cfd
+16 -2
View File
@@ -1,5 +1,5 @@
import numpy as np
from numpy.testing import assert_almost_equal, assert_equal
from numpy.testing import assert_almost_equal, assert_equal, assert_raises
from skimage.morphology import diamond
from skimage.feature import match_template, peak_local_max
@@ -88,7 +88,7 @@ def test_no_nans():
def test_switched_arguments():
image = np.ones((5, 5))
template = np.ones((3, 3))
np.testing.assert_raises(ValueError, match_template, template, image)
assert_raises(ValueError, match_template, template, image)
def test_pad_input():
@@ -145,6 +145,20 @@ def test_3d_pad_input():
assert_equal(np.unravel_index(result.argmax(), image.shape), (4, 6, 5))
def test_wrong_input():
image = np.ones((5, 5, 1))
template = np.ones((3, 3))
assert_raises(ValueError, match_template, template, image)
image = np.ones((5, 5))
template = np.ones((3, 3, 2))
assert_raises(ValueError, match_template, template, image)
image = np.ones((5, 5, 3, 3))
template = np.ones((3, 3, 2))
assert_raises(ValueError, match_template, template, image)
if __name__ == "__main__":
from numpy import testing
testing.run_module_suite()