"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "skimage/filters/rank/tests/test_rank.py" between
scikit-image-0.18.1.tar.gz and scikit-image-0.18.3.tar.gz

About: scikit-image is a collection of algorithms for image processing in Python.

test_rank.py  (scikit-image-0.18.1):test_rank.py  (scikit-image-0.18.3)
skipping to change at line 69 skipping to change at line 69
arr = np.array([[10, 10, 10]], dtype=dtype) arr = np.array([[10, 10, 10]], dtype=dtype)
result = subtract_mean(arr, selem) result = subtract_mean(arr, selem)
if dtype == np.uint8: if dtype == np.uint8:
expected_val = 127 expected_val = 127
else: else:
expected_val = (arr.max() + 1) // 2 - 1 expected_val = (arr.max() + 1) // 2 - 1
assert np.all(result == expected_val) assert np.all(result == expected_val)
@pytest.fixture(scope='module') # Note: Explicitly read all values into a dict. Otherwise, stochastic test
def refs(): # failures related to I/O can occur during parallel test cases.
yield np.load(fetch("data/rank_filter_tests.npz")) ref_data = dict(np.load(fetch("data/rank_filter_tests.npz")))
ref_data_3d = dict(np.load(fetch('data/rank_filters_tests_3d.npz')))
@pytest.fixture(scope='module')
def refs():
yield np.load(fetch("data/rank_filter_tests.npz"))
class TestRank(): class TestRank():
def setup(self): def setup(self):
np.random.seed(0) np.random.seed(0)
# This image is used along with @test_parallel # This image is used along with @test_parallel
# to ensure that the same seed is used for each thread. # to ensure that the same seed is used for each thread.
self.image = np.random.rand(25, 25) self.image = np.random.rand(25, 25)
np.random.seed(0) np.random.seed(0)
self.volume = np.random.rand(10, 10, 10) self.volume = np.random.rand(10, 10, 10)
# Set again the seed for the other tests. # Set again the seed for the other tests.
np.random.seed(0) np.random.seed(0)
self.selem = morphology.disk(1) self.selem = morphology.disk(1)
self.selem_3d = morphology.ball(1) self.selem_3d = morphology.ball(1)
self.refs = np.load(fetch('data/rank_filter_tests.npz')) self.refs = ref_data
self.refs_3d = np.load(fetch('data/rank_filters_tests_3d.npz')) self.refs_3d = ref_data_3d
@parametrize('filter', all_rank_filters) @parametrize('filter', all_rank_filters)
def test_rank_filter(self, filter): def test_rank_filter(self, filter):
@test_parallel(warnings_matching=['Possible precision loss']) @test_parallel(warnings_matching=['Possible precision loss'])
def check(): def check():
expected = self.refs[filter] expected = self.refs[filter]
result = getattr(rank, filter)(self.image, self.selem) result = getattr(rank, filter)(self.image, self.selem)
if filter == "entropy": if filter == "entropy":
# There may be some arch dependent rounding errors # There may be some arch dependent rounding errors
# See the discussions in # See the discussions in
 End of changes. 2 change blocks. 
9 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)