rank filter asserts input is 2d

This commit is contained in:
Andreas Mueller
2011-09-26 19:50:34 +02:00
parent 3b713d67bb
commit e6f660d49d
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -43,6 +43,9 @@ def median_filter(data, mask=None, radius=1, percent=50):
'''
if data.ndim!=2:
raise TypeError("The input 'data' must be a two dimensional array.")
if mask is None:
mask = np.ones(data.shape, dtype=np.bool)
mask = np.ascontiguousarray(mask, dtype=np.bool)
+7
View File
@@ -101,5 +101,12 @@ def test_default_values():
result2 = median_filter(img)
assert_array_equal(result1, result2)
def test_default_values():
img = (np.random.random((20, 20)) * 255).astype(np.uint8)
mask = np.ones((20, 20), dtype=np.uint8)
result1 = median_filter(img, mask, radius=1, percent=50)
result2 = median_filter(img)
assert_array_equal(result1, result2)
if __name__ == "__main__":
run_module_suite()