Source: skimage Version: 0.14.2-1 Severity: important User: debian...@lists.debian.org Usertags: needs-update Control: affects -1 src:python-scipy
[X-Debbugs-CC: debian...@lists.debian.org, python-sc...@packages.debian.org, debian-rele...@lists.debian.org] Dear maintainers, With a recent upload of python-scipy the autopkgtest of skimage fails in testing when that autopkgtest is run with the binary packages of python-scipy from unstable. It passes when run with only packages from testing. In tabular form: pass fail python-scipy from testing 1.1.0-4 skimage from testing 0.14.2-1 all others from testing from testing The latest upload of python-scipy was an effort to fix the autopkgtest of python-scipy (see bug 919929 for background info), which was blurred by loads of deprecation warnings from python-numpy. As part of the solution, python-scipy was patched to prevent specific deprecation warnings, but apparently the autopkgtest of skimage relies on these warnings. I copied some of the output at the bottom of this report. If I read the text in your error log correctly, you can mark the check for these warnings as optional. Can you please do that? Or discuss with the python-scipy maintainers how to resolve this issue. Paul https://ci.debian.net/data/autopkgtest/testing/amd64/s/skimage/2107462/log.gz =================================== FAILURES =================================== __________________________________ test_2d_bf __________________________________ def test_2d_bf(): lx = 70 ly = 100 data, labels = make_2d_syntheticdata(lx, ly) with expected_warnings([NUMPY_MATRIX_WARNING]): > labels_bf = random_walker(data, labels, beta=90, mode='bf') /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError __________________________________ test_2d_cg __________________________________ def test_2d_cg(): lx = 70 ly = 100 data, labels = make_2d_syntheticdata(lx, ly) with expected_warnings(['"cg" mode' + '|' + SCIPY_RANK_WARNING, NUMPY_MATRIX_WARNING]): > labels_cg = random_walker(data, labels, beta=90, mode='cg') /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:100: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['"cg" mode|numpy.linalg.matrix_rank|\\A\\Z', 'matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError ________________________________ test_2d_cg_mg _________________________________ def test_2d_cg_mg(): lx = 70 ly = 100 data, labels = make_2d_syntheticdata(lx, ly) anticipated_warnings = [ 'scipy.sparse.sparsetools|%s' % PYAMG_OR_SCIPY_WARNING, NUMPY_MATRIX_WARNING] with expected_warnings(anticipated_warnings): > labels_cg_mg = random_walker(data, labels, beta=90, mode='cg_mg') /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:121: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['scipy.sparse.sparsetools|numpy.linalg.matrix_rank|\\A\\Z|pyamg|\\A\\Z', 'matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError __________________________________ test_types __________________________________ def test_types(): lx = 70 ly = 100 data, labels = make_2d_syntheticdata(lx, ly) data = 255 * (data - data.min()) // (data.max() - data.min()) data = data.astype(np.uint8) with expected_warnings([PYAMG_OR_SCIPY_WARNING, NUMPY_MATRIX_WARNING]): > labels_cg_mg = random_walker(data, labels, beta=90, mode='cg_mg') /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:140: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['numpy.linalg.matrix_rank|\\A\\Z|pyamg|\\A\\Z', 'matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError _____________________________ test_reorder_labels ______________________________ def test_reorder_labels(): lx = 70 ly = 100 data, labels = make_2d_syntheticdata(lx, ly) labels[labels == 2] = 4 with expected_warnings([NUMPY_MATRIX_WARNING]): > labels_bf = random_walker(data, labels, beta=90, mode='bf') /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:152: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError _______________________________ test_2d_inactive _______________________________ def test_2d_inactive(): lx = 70 ly = 100 data, labels = make_2d_syntheticdata(lx, ly) labels[10:20, 10:20] = -1 labels[46:50, 33:38] = -2 with expected_warnings([NUMPY_MATRIX_WARNING]): > labels = random_walker(data, labels, beta=90) /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:165: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError ___________________________________ test_3d ____________________________________ def test_3d(): n = 30 lx, ly, lz = n, n, n data, labels = make_3d_syntheticdata(lx, ly, lz) with expected_warnings(['"cg" mode' + '|' + SCIPY_RANK_WARNING, NUMPY_MATRIX_WARNING]): > labels = random_walker(data, labels, mode='cg') /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:177: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['"cg" mode|numpy.linalg.matrix_rank|\\A\\Z', 'matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError _______________________________ test_3d_inactive _______________________________ def test_3d_inactive(): n = 30 lx, ly, lz = n, n, n data, labels = make_3d_syntheticdata(lx, ly, lz) old_labels = np.copy(labels) labels[5:25, 26:29, 26:29] = -1 after_labels = np.copy(labels) with expected_warnings(['"cg" mode|CObject type' + '|' + SCIPY_RANK_WARNING, NUMPY_MATRIX_WARNING]): > labels = random_walker(data, labels, mode='cg') /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['"cg" mode|CObject type|numpy.linalg.matrix_rank|\\A\\Z', 'matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError ____________________________ test_multispectral_2d _____________________________ def test_multispectral_2d(): lx, ly = 70, 100 data, labels = make_2d_syntheticdata(lx, ly) data = data[..., np.newaxis].repeat(2, axis=-1) # Expect identical output with expected_warnings(['"cg" mode' + '|' + SCIPY_RANK_WARNING, NUMPY_MATRIX_WARNING]): multi_labels = random_walker(data, labels, mode='cg', > multichannel=True) /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:205: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['"cg" mode|numpy.linalg.matrix_rank|\\A\\Z', 'matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError ____________________________ test_multispectral_3d _____________________________ def test_multispectral_3d(): n = 30 lx, ly, lz = n, n, n data, labels = make_3d_syntheticdata(lx, ly, lz) data = data[..., np.newaxis].repeat(2, axis=-1) # Expect identical output with expected_warnings(['"cg" mode' + '|' + SCIPY_RANK_WARNING, NUMPY_MATRIX_WARNING]): multi_labels = random_walker(data, labels, mode='cg', > multichannel=True) /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:223: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['"cg" mode|numpy.linalg.matrix_rank|\\A\\Z', 'matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError ________________________________ test_spacing_0 ________________________________ def test_spacing_0(): n = 30 lx, ly, lz = n, n, n data, _ = make_3d_syntheticdata(lx, ly, lz) # Rescale `data` along Z axis data_aniso = np.zeros((n, n, n // 2)) for i, yz in enumerate(data): data_aniso[i, :, :] = resize(yz, (n, n // 2), mode='constant', anti_aliasing=False) # Generate new labels small_l = int(lx // 5) labels_aniso = np.zeros_like(data_aniso) labels_aniso[lx // 5, ly // 5, lz // 5] = 1 labels_aniso[lx // 2 + small_l // 4, ly // 2 - small_l // 4, lz // 4 - small_l // 8] = 2 # Test with `spacing` kwarg with expected_warnings(['"cg" mode' + '|' + SCIPY_RANK_WARNING, NUMPY_MATRIX_WARNING]): labels_aniso = random_walker(data_aniso, labels_aniso, mode='cg', > spacing=(1., 1., 0.5)) /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:258: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['"cg" mode|numpy.linalg.matrix_rank|\\A\\Z', 'matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError ________________________________ test_spacing_1 ________________________________ @xfail(condition=arch32, reason=('Known test failure on 32-bit platforms. See links for ' 'details: ' 'https://github.com/scikit-image/scikit-image/issues/3091 ' 'https://github.com/scikit-image/scikit-image/issues/3092')) def test_spacing_1(): n = 30 lx, ly, lz = n, n, n data, _ = make_3d_syntheticdata(lx, ly, lz) # Rescale `data` along Y axis # `resize` is not yet 3D capable, so this must be done by looping in 2D. data_aniso = np.zeros((n, n * 2, n)) for i, yz in enumerate(data): data_aniso[i, :, :] = resize(yz, (n * 2, n), mode='constant', anti_aliasing=False) # Generate new labels small_l = int(lx // 5) labels_aniso = np.zeros_like(data_aniso) labels_aniso[lx // 5, ly // 5, lz // 5] = 1 labels_aniso[lx // 2 + small_l // 4, ly - small_l // 2, lz // 2 - small_l // 4] = 2 # Test with `spacing` kwarg # First, anisotropic along Y with expected_warnings(['"cg" mode' + '|' + SCIPY_RANK_WARNING, NUMPY_MATRIX_WARNING]): labels_aniso = random_walker(data_aniso, labels_aniso, mode='cg', > spacing=(1., 2., 1.)) /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:294: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['"cg" mode|numpy.linalg.matrix_rank|\\A\\Z', 'matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError _____________________________ test_length2_spacing _____________________________ def test_length2_spacing(): # If this passes without raising an exception (warnings OK), the new # spacing code is working properly. np.random.seed(42) img = np.ones((10, 10)) + 0.2 * np.random.normal(size=(10, 10)) labels = np.zeros((10, 10), dtype=np.uint8) labels[2, 4] = 1 labels[6, 8] = 4 with expected_warnings([NUMPY_MATRIX_WARNING]): > random_walker(img, labels, spacing=(1., 2.)) /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:349: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError _____________________________ test_isolated_seeds ______________________________ def test_isolated_seeds(): np.random.seed(0) a = np.random.random((7, 7)) mask = - np.ones(a.shape) # This pixel is an isolated seed mask[1, 1] = 1 # Unlabeled pixels mask[3:, 3:] = 0 # Seeds connected to unlabeled pixels mask[4, 4] = 2 mask[6, 6] = 1 # Test that no error is raised, and that labels of isolated seeds are OK with expected_warnings([NUMPY_MATRIX_WARNING]): > res = random_walker(a, mask) /usr/lib/python3/dist-packages/skimage/segmentation/tests/test_random_walker.py:399: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.7/contextlib.py:119: in __exit__ next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ matching = ['matrix subclass'] @contextmanager def expected_warnings(matching): """Context for use in testing to catch known warnings matching regexes Parameters ---------- matching : list of strings or compiled regexes Regexes for the desired warning to catch Examples -------- >>> from skimage import data, img_as_ubyte, img_as_float >>> with expected_warnings(['precision loss']): ... d = img_as_ubyte(img_as_float(data.coins())) Notes ----- Uses `all_warnings` to ensure all warnings are raised. Upon exiting, it checks the recorded warnings for the desired matching pattern(s). Raises a ValueError if any match was not found or an unexpected warning was raised. Allows for three types of behaviors: `and`, `or`, and `optional` matches. This is done to accomodate different build enviroments or loop conditions that may produce different warnings. The behaviors can be combined. If you pass multiple patterns, you get an orderless `and`, where all of the warnings must be raised. If you use the `|` operator in a pattern, you can catch one of several warnings. Finally, you can use `|\A\Z` in a pattern to signify it as optional. """ if isinstance(matching, str): raise ValueError('``matching`` should be a list of strings and not ' 'a string itself.') with all_warnings() as w: # enter context yield w # exited user context, check the recorded warnings # Allow users to provide None while None in matching: matching.remove(None) remaining = [m for m in matching if '\A\Z' not in m.split('|')] for warn in w: found = False for match in matching: if re.search(match, str(warn.message)) is not None: found = True if match in remaining: remaining.remove(match) if not found: raise ValueError('Unexpected warning: %s' % str(warn.message)) if len(remaining) > 0: msg = 'No warning raised matching:\n%s' % '\n'.join(remaining) > raise ValueError(msg) E ValueError: No warning raised matching: E matrix subclass /usr/lib/python3/dist-packages/skimage/_shared/_warnings.py:130: ValueError
signature.asc
Description: OpenPGP digital signature