Merge pull request #460 from jni/raise-type

BUG: Revert `remove_small_objects` to raise TypeError.
This commit is contained in:
Stefan van der Walt
2013-03-10 21:42:45 -07:00
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -21,8 +21,10 @@ def remove_small_objects(ar, min_size=64, connectivity=1, in_place=False):
Raises
------
ValueError
TypeError
If the input array is of an invalid type, such as float or string.
ValueError
If the input array contains negative values.
Returns
-------
@@ -50,9 +52,9 @@ def remove_small_objects(ar, min_size=64, connectivity=1, in_place=False):
>>> d is a
True
"""
# Should use `issubdtype` below, but there's a bug in numpy 1.7
# Should use `issubdtype` for bool below, but there's a bug in numpy 1.7
if not (ar.dtype == bool or np.issubdtype(ar.dtype, int)):
raise ValueError("Only bool or integer image types are supported. "
raise TypeError("Only bool or integer image types are supported. "
"Got %s." % ar.dtype)
if in_place:
+1 -1
View File
@@ -44,7 +44,7 @@ def test_labeled_image():
def test_float_input():
float_test = np.random.rand(5, 5)
assert_raises(ValueError, remove_small_objects, float_test)
assert_raises(TypeError, remove_small_objects, float_test)
def test_negative_input():