Created
December 11, 2015 19:57
-
-
Save bsipocz/50d5545f43f5be193ff5 to your computer and use it in GitHub Desktop.
py.test scikit-image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(astropy-dev)bsipocz@tegla2:~/munka/devel/scikit-image$ py.test | |
================================================== test session starts ================================================== | |
platform darwin -- Python 2.7.10, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 | |
rootdir: /Users/bsipocz/munka/devel/scikit-image, inifile: | |
plugins: cov-2.1.0, html-1.6, mpl-0.3, selenium-1.0b1, variables-1.2 | |
collected 1319 items / 3 skipped | |
skimage/_shared/tests/test_interpolation.py F | |
skimage/_shared/tests/test_safe_as_int.py .. | |
skimage/_shared/tests/test_testing.py .F. | |
skimage/_shared/tests/test_version_requirements.py .... | |
skimage/color/tests/test_adapt_rgb.py ...... | |
skimage/color/tests/test_colorconv.py ...................................... | |
skimage/color/tests/test_colorlabel.py ........... | |
skimage/color/tests/test_delta_e.py ........ | |
skimage/data/tests/test_data.py ........... | |
skimage/draw/tests/test_draw.py .................................... | |
skimage/draw/tests/test_draw3d.py ...... | |
skimage/exposure/tests/test_exposure.py .......................FFF............. | |
skimage/external/test_tifffile.py .................. | |
skimage/feature/tests/test_blob.py .... | |
skimage/feature/tests/test_brief.py ...... | |
skimage/feature/tests/test_canny.py ...... | |
skimage/feature/tests/test_censure.py ........ | |
skimage/feature/tests/test_corner.py ....................... | |
skimage/feature/tests/test_daisy.py ....... | |
skimage/feature/tests/test_hog.py ..... | |
skimage/feature/tests/test_match.py ..... | |
skimage/feature/tests/test_orb.py .... | |
skimage/feature/tests/test_peak.py ....................... | |
skimage/feature/tests/test_register_translation.py ......... | |
skimage/feature/tests/test_template.py .......... | |
skimage/feature/tests/test_texture.py ..................... | |
skimage/feature/tests/test_util.py ..... | |
skimage/filters/rank/tests/test_rank.py .............................. | |
skimage/filters/tests/test_deprecated_imports.py .. | |
skimage/filters/tests/test_edges.py .............................................. | |
skimage/filters/tests/test_gabor.py ...... | |
skimage/filters/tests/test_gaussian.py ... | |
skimage/filters/tests/test_lpi_filter.py FFFFF. | |
skimage/filters/tests/test_median.py . | |
skimage/filters/tests/test_thresholding.py ...................................... | |
skimage/future/graph/tests/test_rag.py ...... | |
skimage/graph/tests/test_anisotropy.py . | |
skimage/graph/tests/test_connect.py . | |
skimage/graph/tests/test_flexible.py . | |
skimage/graph/tests/test_heap.py .. | |
skimage/graph/tests/test_mcp.py ............... | |
skimage/graph/tests/test_spath.py ... | |
skimage/io/tests/test_collection.py ..FFFF.FF | |
skimage/io/tests/test_colormixer.py ..................... | |
skimage/io/tests/test_fits.py ..... | |
skimage/io/tests/test_freeimage.py sssssssE | |
skimage/io/tests/test_histograms.py .....E | |
skimage/io/tests/test_imread.py ssssE | |
skimage/io/tests/test_io.py ... | |
skimage/io/tests/test_mpl_imshow.py ....... | |
skimage/io/tests/test_multi_image.py FFFFFFF | |
skimage/io/tests/test_pil.py ...................................................... | |
skimage/io/tests/test_plugin.py ............ | |
skimage/io/tests/test_plugin_util.py ..........E | |
skimage/io/tests/test_sift.py .. | |
skimage/io/tests/test_simpleitk.py ssss | |
skimage/io/tests/test_tifffile.py .................. | |
skimage/measure/tests/test_block.py ...... | |
skimage/measure/tests/test_find_contours.py .... | |
skimage/measure/tests/test_fit.py .................... | |
skimage/measure/tests/test_marching_cubes.py .... | |
skimage/measure/tests/test_moments.py ..... | |
skimage/measure/tests/test_pnpoly.py . | |
skimage/measure/tests/test_polygon.py .. | |
skimage/measure/tests/test_profile.py .............. | |
skimage/measure/tests/test_regionprops.py ...................................... | |
skimage/measure/tests/test_structural_similarity.py ............ | |
skimage/morphology/tests/test_binary.py ................. | |
skimage/morphology/tests/test_ccomp.py ................... | |
skimage/morphology/tests/test_convex_hull.py ..... | |
skimage/morphology/tests/test_grey.py ..........FFFFFFFFF............... | |
skimage/morphology/tests/test_misc.py ........ | |
skimage/morphology/tests/test_reconstruction.py .......... | |
skimage/morphology/tests/test_selem.py .......... | |
skimage/morphology/tests/test_skeletonize.py ................ | |
skimage/morphology/tests/test_watershed.py ........... | |
skimage/novice/tests/test_novice.py ........................... | |
skimage/restoration/tests/test_denoise.py ................ | |
skimage/restoration/tests/test_restoration.py .... | |
skimage/restoration/tests/test_unwrap.py ................ | |
skimage/segmentation/tests/test_boundaries.py ... | |
skimage/segmentation/tests/test_clear_border.py . | |
skimage/segmentation/tests/test_felzenszwalb.py .... | |
skimage/segmentation/tests/test_join.py ..... | |
skimage/segmentation/tests/test_quickshift.py ... | |
skimage/segmentation/tests/test_random_walker.py ............... | |
skimage/segmentation/tests/test_slic.py ........... | |
skimage/transform/tests/test_finite_radon_transform.py . | |
skimage/transform/tests/test_geometric.py .................... | |
skimage/transform/tests/test_hough_transform.py ................... | |
skimage/transform/tests/test_integral.py .... | |
skimage/transform/tests/test_pyramids.py ......... | |
skimage/transform/tests/test_radon_transform.py .................................................................... | |
skimage/transform/tests/test_seam_carving.py . | |
skimage/transform/tests/test_warps.py ......................... | |
skimage/util/tests/test_apply_parallel.py .... | |
skimage/util/tests/test_arraypad.py ................................................................... | |
skimage/util/tests/test_dtype.py .................................. | |
skimage/util/tests/test_montage.py ...... | |
skimage/util/tests/test_random_noise.py ............ | |
skimage/util/tests/test_regular_grid.py .... | |
skimage/util/tests/test_shape.py .................. | |
skimage/util/tests/test_unique_rows.py ..... | |
skimage/viewer/tests/test_plugins.py .......... | |
skimage/viewer/tests/test_tools.py ..F.. | |
skimage/viewer/tests/test_utils.py .... | |
skimage/viewer/tests/test_viewer.py ... | |
skimage/viewer/tests/test_widgets.py ....... | |
======================================================== ERRORS ========================================================= | |
________________________________________________ ERROR at setup of test _________________________________________________ | |
file /sw/lib/python2.7/site-packages/numpy/testing/nosetester.py, line 319 | |
def test(self, label='fast', verbose=1, extra_argv=None, | |
fixture 'self' not found | |
available fixtures: _skip_sensitive, tmpdir_factory, pytestconfig, _verify_url, cov, _environment, cache, selenium, recwarn, capabilities, base_url, environment, sensitive_url, monkeypatch, record_xml_property, capfd, variables, capsys, tmpdir | |
use 'py.test --fixtures [testpath]' for help on them. | |
/sw/lib/python2.7/site-packages/numpy/testing/nosetester.py:319 | |
________________________________________________ ERROR at setup of test _________________________________________________ | |
file /sw/lib/python2.7/site-packages/numpy/testing/nosetester.py, line 319 | |
def test(self, label='fast', verbose=1, extra_argv=None, | |
fixture 'self' not found | |
available fixtures: _skip_sensitive, tmpdir_factory, pytestconfig, _verify_url, cov, _environment, cache, selenium, recwarn, capabilities, base_url, environment, sensitive_url, monkeypatch, record_xml_property, capfd, variables, capsys, tmpdir | |
use 'py.test --fixtures [testpath]' for help on them. | |
/sw/lib/python2.7/site-packages/numpy/testing/nosetester.py:319 | |
________________________________________________ ERROR at setup of test _________________________________________________ | |
file /sw/lib/python2.7/site-packages/numpy/testing/nosetester.py, line 319 | |
def test(self, label='fast', verbose=1, extra_argv=None, | |
fixture 'self' not found | |
available fixtures: _skip_sensitive, tmpdir_factory, pytestconfig, _verify_url, cov, _environment, cache, selenium, recwarn, capabilities, base_url, environment, sensitive_url, monkeypatch, record_xml_property, capfd, variables, capsys, tmpdir | |
use 'py.test --fixtures [testpath]' for help on them. | |
/sw/lib/python2.7/site-packages/numpy/testing/nosetester.py:319 | |
________________________________________________ ERROR at setup of test _________________________________________________ | |
file /sw/lib/python2.7/site-packages/numpy/testing/nosetester.py, line 319 | |
def test(self, label='fast', verbose=1, extra_argv=None, | |
fixture 'self' not found | |
available fixtures: _skip_sensitive, tmpdir_factory, pytestconfig, _verify_url, cov, _environment, cache, selenium, recwarn, capabilities, base_url, environment, sensitive_url, monkeypatch, record_xml_property, capfd, variables, capsys, tmpdir | |
use 'py.test --fixtures [testpath]' for help on them. | |
/sw/lib/python2.7/site-packages/numpy/testing/nosetester.py:319 | |
======================================================= FAILURES ======================================================== | |
____________________________________________________ test_coord_map _____________________________________________________ | |
def test_coord_map(): | |
symmetric = [coord_map_py(4, n, 'S') for n in range(-6, 6)] | |
expected_symmetric = [2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2] | |
assert_array_equal(symmetric, expected_symmetric) | |
wrap = [coord_map_py(4, n, 'W') for n in range(-6, 6)] | |
expected_wrap = [2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1] | |
assert_array_equal(wrap, expected_wrap) | |
edge = [coord_map_py(4, n, 'E') for n in range(-6, 6)] | |
expected_edge = [0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 3, 3] | |
assert_array_equal(edge, expected_edge) | |
reflect = [coord_map_py(4, n, 'R') for n in range(-6, 6)] | |
expected_reflect = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1] | |
assert_array_equal(reflect, expected_reflect) | |
constant = [coord_map_py(4, n, 'C') for n in range(-6, 6)] | |
expected_constant = [0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0] | |
> assert_array_equal(constant, expected_constant) | |
skimage/_shared/tests/test_interpolation.py:24: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/sw/lib/python2.7/site-packages/numpy/testing/utils.py:782: in assert_array_equal | |
verbose=verbose, header='Arrays are not equal') | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
comparison = <built-in function __eq__>, x = array([-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) | |
y = array([0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0]), err_msg = '', verbose = True, header = 'Arrays are not equal' | |
precision = 6 | |
def assert_array_compare(comparison, x, y, err_msg='', verbose=True, | |
header='', precision=6): | |
from numpy.core import array, isnan, isinf, any, all, inf | |
x = array(x, copy=False, subok=True) | |
y = array(y, copy=False, subok=True) | |
def safe_comparison(*args, **kwargs): | |
# There are a number of cases where comparing two arrays hits special | |
# cases in array_richcompare, specifically around strings and void | |
# dtypes. Basically, we just can't do comparisons involving these | |
# types, unless both arrays have exactly the *same* type. So | |
# e.g. you can apply == to two string arrays, or two arrays with | |
# identical structured dtypes. But if you compare a non-string array | |
# to a string array, or two arrays with non-identical structured | |
# dtypes, or anything like that, then internally stuff blows up. | |
# Currently, when things blow up, we just return a scalar False or | |
# True. But we also emit a DeprecationWarning, b/c eventually we | |
# should raise an error here. (Ideally we might even make this work | |
# properly, but since that will require rewriting a bunch of how | |
# ufuncs work then we are not counting on that.) | |
# | |
# The point of this little function is to let the DeprecationWarning | |
# pass (or maybe eventually catch the errors and return False, I | |
# dunno, that's a little trickier and we can figure that out when the | |
# time comes). | |
with warnings.catch_warnings(): | |
warnings.filterwarnings("ignore", category=DeprecationWarning) | |
return comparison(*args, **kwargs) | |
def isnumber(x): | |
return x.dtype.char in '?bhilqpBHILQPefdgFDG' | |
def chk_same_position(x_id, y_id, hasval='nan'): | |
"""Handling nan/inf: check that x and y have the nan/inf at the same | |
locations.""" | |
try: | |
assert_array_equal(x_id, y_id) | |
except AssertionError: | |
msg = build_err_msg([x, y], | |
err_msg + '\nx and y %s location mismatch:' | |
% (hasval), verbose=verbose, header=header, | |
names=('x', 'y'), precision=precision) | |
raise AssertionError(msg) | |
try: | |
cond = (x.shape == () or y.shape == ()) or x.shape == y.shape | |
if not cond: | |
msg = build_err_msg([x, y], | |
err_msg | |
+ '\n(shapes %s, %s mismatch)' % (x.shape, | |
y.shape), | |
verbose=verbose, header=header, | |
names=('x', 'y'), precision=precision) | |
if not cond: | |
raise AssertionError(msg) | |
if isnumber(x) and isnumber(y): | |
x_isnan, y_isnan = isnan(x), isnan(y) | |
x_isinf, y_isinf = isinf(x), isinf(y) | |
# Validate that the special values are in the same place | |
if any(x_isnan) or any(y_isnan): | |
chk_same_position(x_isnan, y_isnan, hasval='nan') | |
if any(x_isinf) or any(y_isinf): | |
# Check +inf and -inf separately, since they are different | |
chk_same_position(x == +inf, y == +inf, hasval='+inf') | |
chk_same_position(x == -inf, y == -inf, hasval='-inf') | |
# Combine all the special values | |
x_id, y_id = x_isnan, y_isnan | |
x_id |= x_isinf | |
y_id |= y_isinf | |
# Only do the comparison if actual values are left | |
if all(x_id): | |
return | |
if any(x_id): | |
val = safe_comparison(x[~x_id], y[~y_id]) | |
else: | |
val = safe_comparison(x, y) | |
else: | |
val = safe_comparison(x, y) | |
if isinstance(val, bool): | |
cond = val | |
reduced = [0] | |
else: | |
reduced = val.ravel() | |
cond = reduced.all() | |
reduced = reduced.tolist() | |
if not cond: | |
match = 100-100.0*reduced.count(1)/len(reduced) | |
msg = build_err_msg([x, y], | |
err_msg | |
+ '\n(mismatch %s%%)' % (match,), | |
verbose=verbose, header=header, | |
names=('x', 'y'), precision=precision) | |
if not cond: | |
> raise AssertionError(msg) | |
E AssertionError: | |
E Arrays are not equal | |
E | |
E (mismatch 66.6666666667%) | |
E x: array([-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) | |
E y: array([0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0]) | |
/sw/lib/python2.7/site-packages/numpy/testing/utils.py:708: AssertionError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
_____________________________________________________ test_skipper ______________________________________________________ | |
def test_skipper(): | |
def f(): | |
pass | |
class c(): | |
def __init__(self): | |
self.me = "I think, therefore..." | |
docstring = \ | |
""" Header | |
>>> something # skip if not HAVE_AMODULE | |
>>> something + else | |
>>> a = 1 # skip if not HAVE_BMODULE | |
>>> something2 # skip if HAVE_AMODULE | |
""" | |
f.__doc__ = docstring | |
c.__doc__ = docstring | |
global HAVE_AMODULE, HAVE_BMODULE | |
HAVE_AMODULE = False | |
HAVE_BMODULE = True | |
f2 = doctest_skip_parser(f) | |
c2 = doctest_skip_parser(c) | |
assert_true(f is f2) | |
assert_true(c is c2) | |
assert_equal(f2.__doc__, | |
""" Header | |
>>> something # doctest: +SKIP | |
>>> something + else | |
>>> a = 1 | |
>>> something2 | |
> """) | |
skimage/_shared/tests/test_testing.py:45: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/sw/lib/python2.7/unittest/case.py:515: in assertEqual | |
assertion_func(first, second, msg=msg) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <nose.tools.trivial.Dummy testMethod=nop> | |
first = ' Header\n\n >>> something # doctest: +SKIP\n >>> something + else\n >>> a = 1\n >>> something2\n ' | |
second = ' Header\n\n >>> something # doctest: +SKIP\n >>> something + else\n >>> a = 1\n >>> something2\n ' | |
msg = "' Header\\n\\n >>> something # doctest: +SKIP\\n >>> something + else\\n >>> a = 1\\n >>>... >>> something + else\\n >>> a = 1\\n >>> something2\\n '" | |
def _baseAssertEqual(self, first, second, msg=None): | |
"""The default assertEqual implementation, not type specific.""" | |
if not first == second: | |
standardMsg = '%s != %s' % (safe_repr(first), safe_repr(second)) | |
msg = self._formatMessage(msg, standardMsg) | |
> raise self.failureException(msg) | |
E AssertionError: ' Header\n\n >>> something # doctest: +SKIP\n >>> something + else\n >>> a = 1\n >>> something2\n ' != ' Header\n\n >>> something # doctest: +SKIP\n >>> something + else\n >>> a = 1\n >>> something2\n ' | |
/sw/lib/python2.7/unittest/case.py:508: AssertionError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
_______________________________________________ test_adapthist_grayscale ________________________________________________ | |
def test_adapthist_grayscale(): | |
"""Test a grayscale float image | |
""" | |
img = skimage.img_as_float(data.astronaut()) | |
img = rgb2gray(img) | |
img = np.dstack((img, img, img)) | |
with expected_warnings(['precision loss|non-contiguous input', | |
'deprecated']): | |
adapted_old = exposure.equalize_adapthist(img, 10, 9, clip_limit=0.01, | |
nbins=128) | |
> adapted = exposure.equalize_adapthist(img, kernel_size=(57, 51), clip_limit=0.01, nbins=128) | |
skimage/exposure/tests/test_exposure.py:218: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/sw/lib/python2.7/contextlib.py:24: in __exit__ | |
self.gen.next() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
matching = ['precision loss|non-contiguous input', 'deprecated'] | |
@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. | |
""" | |
with all_warnings() as w: | |
# enter context | |
yield w | |
# exited user context, check the recorded warnings | |
remaining = [m for m in matching if not '\A\Z' 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)) | |
E ValueError: Unexpected warning: boolean index did not match indexed array along dimension 0; dimension is 128 but corresponding boolean dimension is 127 | |
skimage/_shared/_warnings.py:112: ValueError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
_________________________________________________ test_adapthist_color __________________________________________________ | |
def test_adapthist_color(): | |
"""Test an RGB color uint16 image | |
""" | |
img = skimage.img_as_uint(data.astronaut()) | |
with warnings.catch_warnings(record=True) as w: | |
warnings.simplefilter('always') | |
hist, bin_centers = exposure.histogram(img) | |
assert len(w) > 0 | |
with expected_warnings(['precision loss', 'deprecated']): | |
> adapted = exposure.equalize_adapthist(img, clip_limit=0.01) | |
skimage/exposure/tests/test_exposure.py:234: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/sw/lib/python2.7/contextlib.py:24: in __exit__ | |
self.gen.next() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
matching = ['precision loss', 'deprecated'] | |
@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. | |
""" | |
with all_warnings() as w: | |
# enter context | |
yield w | |
# exited user context, check the recorded warnings | |
remaining = [m for m in matching if not '\A\Z' 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)) | |
E ValueError: Unexpected warning: boolean index did not match indexed array along dimension 0; dimension is 256 but corresponding boolean dimension is 86 | |
skimage/_shared/_warnings.py:112: ValueError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
_________________________________________________ test_adapthist_alpha __________________________________________________ | |
def test_adapthist_alpha(): | |
"""Test an RGBA color image | |
""" | |
img = skimage.img_as_float(data.astronaut()) | |
alpha = np.ones((img.shape[0], img.shape[1]), dtype=float) | |
img = np.dstack((img, alpha)) | |
with expected_warnings(['precision loss', 'deprecated']): | |
> adapted = exposure.equalize_adapthist(img) | |
skimage/exposure/tests/test_exposure.py:253: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/sw/lib/python2.7/contextlib.py:24: in __exit__ | |
self.gen.next() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
matching = ['precision loss', 'deprecated'] | |
@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. | |
""" | |
with all_warnings() as w: | |
# enter context | |
yield w | |
# exited user context, check the recorded warnings | |
remaining = [m for m in matching if not '\A\Z' 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)) | |
E ValueError: Unexpected warning: boolean index did not match indexed array along dimension 0; dimension is 256 but corresponding boolean dimension is 86 | |
skimage/_shared/_warnings.py:112: ValueError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
___________________________________________ TestLPIFilter2D.test_ip_shape[0] ____________________________________________ | |
self = <skimage.filters.tests.test_lpi_filter.TestLPIFilter2D object at 0x10db4ad10> | |
x = array([[156, 157, 160, ..., 161, 161, 162], | |
[156, 157, 159, ..., 161, 1... ..., 159, 159, 158], | |
[153, 154, 154, ..., 160, 159, 158]], dtype=uint8) | |
def tst_shape(self, x): | |
> X = self.f(x) | |
E AttributeError: 'TestLPIFilter2D' object has no attribute 'f' | |
skimage/filters/tests/test_lpi_filter.py:19: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
___________________________________________ TestLPIFilter2D.test_ip_shape[1] ____________________________________________ | |
self = <skimage.filters.tests.test_lpi_filter.TestLPIFilter2D object at 0x10db4ad10> | |
x = array([[156, 157, 160, ..., 160, 162, 166], | |
[156, 157, 159, ..., 160, 1... ..., 159, 159, 159], | |
[153, 154, 154, ..., 159, 159, 160]], dtype=uint8) | |
def tst_shape(self, x): | |
> X = self.f(x) | |
E AttributeError: 'TestLPIFilter2D' object has no attribute 'f' | |
skimage/filters/tests/test_lpi_filter.py:19: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
___________________________________________ TestLPIFilter2D.test_ip_shape[2] ____________________________________________ | |
self = <skimage.filters.tests.test_lpi_filter.TestLPIFilter2D object at 0x10db4ad10> | |
x = array([[156, 157, 160, ..., 160, 160, 158], | |
[156, 157, 159, ..., 160, 1... ..., 160, 160, 158], | |
[153, 154, 154, ..., 161, 161, 158]], dtype=uint8) | |
def tst_shape(self, x): | |
> X = self.f(x) | |
E AttributeError: 'TestLPIFilter2D' object has no attribute 'f' | |
skimage/filters/tests/test_lpi_filter.py:19: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
_____________________________________________ TestLPIFilter2D.test_inverse ______________________________________________ | |
self = <skimage.filters.tests.test_lpi_filter.TestLPIFilter2D object at 0x11d8fc190> | |
def test_inverse(self): | |
> F = self.f(self.img) | |
E AttributeError: 'TestLPIFilter2D' object has no attribute 'f' | |
skimage/filters/tests/test_lpi_filter.py:30: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
______________________________________________ TestLPIFilter2D.test_wiener ______________________________________________ | |
self = <skimage.filters.tests.test_lpi_filter.TestLPIFilter2D object at 0x11d74cf10> | |
def test_wiener(self): | |
> F = self.f(self.img) | |
E AttributeError: 'TestLPIFilter2D' object has no attribute 'f' | |
skimage/filters/tests/test_lpi_filter.py:45: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
_____________________________________________ TestImageCollection.test_len ______________________________________________ | |
self = <skimage.io.tests.test_collection.TestImageCollection instance at 0x1186342d8> | |
def test_len(self): | |
> assert len(self.images) == 2 | |
E AttributeError: TestImageCollection instance has no attribute 'images' | |
skimage/io/tests/test_collection.py:42: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
___________________________________________ TestImageCollection.test_getitem ____________________________________________ | |
self = <skimage.io.tests.test_collection.TestImageCollection instance at 0x1186487a0> | |
def test_getitem(self): | |
> num = len(self.images) | |
E AttributeError: TestImageCollection instance has no attribute 'images' | |
skimage/io/tests/test_collection.py:45: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
___________________________________________ TestImageCollection.test_slicing ____________________________________________ | |
self = <skimage.io.tests.test_collection.TestImageCollection instance at 0x118634710> | |
def test_slicing(self): | |
> assert type(self.images[:]) is ImageCollection | |
E AttributeError: TestImageCollection instance has no attribute 'images' | |
skimage/io/tests/test_collection.py:58: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
________________________________________ TestImageCollection.test_files_property ________________________________________ | |
self = <skimage.io.tests.test_collection.TestImageCollection instance at 0x10d78dc20> | |
def test_files_property(self): | |
> assert isinstance(self.images.files, list) | |
E AttributeError: TestImageCollection instance has no attribute 'images' | |
skimage/io/tests/test_collection.py:68: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
_________________________________________ TestImageCollection.test_concatenate __________________________________________ | |
self = <skimage.io.tests.test_collection.TestImageCollection instance at 0x11d8e7dd0> | |
def test_concatenate(self): | |
> array = self.images_matched.concatenate() | |
E AttributeError: TestImageCollection instance has no attribute 'images_matched' | |
skimage/io/tests/test_collection.py:84: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
_____________________________ TestImageCollection.test_concatentate_mismatched_image_shapes _____________________________ | |
self = <skimage.io.tests.test_collection.TestImageCollection instance at 0x11d72c3f8> | |
def test_concatentate_mismatched_image_shapes(self): | |
> assert_raises(ValueError, self.images.concatenate) | |
E AttributeError: TestImageCollection instance has no attribute 'images' | |
skimage/io/tests/test_collection.py:89: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
______________________________________________ TestMultiImage.test_shapes _______________________________________________ | |
self = <skimage.io.tests.test_multi_image.TestMultiImage instance at 0x118649a28> | |
def test_shapes(self): | |
> img = self.imgs[-1] | |
E AttributeError: TestMultiImage instance has no attribute 'imgs' | |
skimage/io/tests/test_multi_image.py:30: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
________________________________________________ TestMultiImage.test_len ________________________________________________ | |
self = <skimage.io.tests.test_multi_image.TestMultiImage instance at 0x1114dc638> | |
def test_len(self): | |
> assert len(self.imgs[0]) == len(self.imgs[1]) == 2 | |
E AttributeError: TestMultiImage instance has no attribute 'imgs' | |
skimage/io/tests/test_multi_image.py:36: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
______________________________________________ TestMultiImage.test_slicing ______________________________________________ | |
self = <skimage.io.tests.test_multi_image.TestMultiImage instance at 0x11222bb00> | |
def test_slicing(self): | |
> img = self.imgs[-1] | |
E AttributeError: TestMultiImage instance has no attribute 'imgs' | |
skimage/io/tests/test_multi_image.py:43: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
______________________________________________ TestMultiImage.test_getitem ______________________________________________ | |
self = <skimage.io.tests.test_multi_image.TestMultiImage instance at 0x110b24758> | |
def test_getitem(self): | |
> for img in self.imgs: | |
E AttributeError: TestMultiImage instance has no attribute 'imgs' | |
skimage/io/tests/test_multi_image.py:54: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
__________________________________________ TestMultiImage.test_files_property ___________________________________________ | |
self = <skimage.io.tests.test_multi_image.TestMultiImage instance at 0x110b1dd40> | |
def test_files_property(self): | |
> for img in self.imgs: | |
E AttributeError: TestMultiImage instance has no attribute 'imgs' | |
skimage/io/tests/test_multi_image.py:72: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
_____________________________________ TestMultiImage.test_conserve_memory_property ______________________________________ | |
self = <skimage.io.tests.test_multi_image.TestMultiImage instance at 0x110b2b638> | |
def test_conserve_memory_property(self): | |
> for img in self.imgs: | |
E AttributeError: TestMultiImage instance has no attribute 'imgs' | |
skimage/io/tests/test_multi_image.py:83: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
____________________________________________ TestMultiImage.test_concatenate ____________________________________________ | |
self = <skimage.io.tests.test_multi_image.TestMultiImage instance at 0x110b24d40> | |
def test_concatenate(self): | |
> for img in self.imgs: | |
E AttributeError: TestMultiImage instance has no attribute 'imgs' | |
skimage/io/tests/test_multi_image.py:91: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
______________________________ TestEccentricStructuringElements.test_dilate_erode_symmetry ______________________________ | |
self = <skimage.morphology.tests.test_grey.TestEccentricStructuringElements instance at 0x10df7b1b8> | |
def test_dilate_erode_symmetry(self): | |
> for s in self.selems: | |
E AttributeError: TestEccentricStructuringElements instance has no attribute 'selems' | |
skimage/morphology/tests/test_grey.py:79: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
________________________________ TestEccentricStructuringElements.test_open_black_pixel _________________________________ | |
self = <skimage.morphology.tests.test_grey.TestEccentricStructuringElements instance at 0x10df7b248> | |
def test_open_black_pixel(self): | |
> for s in self.selems: | |
E AttributeError: TestEccentricStructuringElements instance has no attribute 'selems' | |
skimage/morphology/tests/test_grey.py:85: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
________________________________ TestEccentricStructuringElements.test_close_white_pixel ________________________________ | |
self = <skimage.morphology.tests.test_grey.TestEccentricStructuringElements instance at 0x10df8b758> | |
def test_close_white_pixel(self): | |
> for s in self.selems: | |
E AttributeError: TestEccentricStructuringElements instance has no attribute 'selems' | |
skimage/morphology/tests/test_grey.py:90: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
________________________________ TestEccentricStructuringElements.test_open_white_pixel _________________________________ | |
self = <skimage.morphology.tests.test_grey.TestEccentricStructuringElements instance at 0x112109290> | |
def test_open_white_pixel(self): | |
> for s in self.selems: | |
E AttributeError: TestEccentricStructuringElements instance has no attribute 'selems' | |
skimage/morphology/tests/test_grey.py:95: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
________________________________ TestEccentricStructuringElements.test_close_black_pixel ________________________________ | |
self = <skimage.morphology.tests.test_grey.TestEccentricStructuringElements instance at 0x10df73440> | |
def test_close_black_pixel(self): | |
> for s in self.selems: | |
E AttributeError: TestEccentricStructuringElements instance has no attribute 'selems' | |
skimage/morphology/tests/test_grey.py:99: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
____________________________ TestEccentricStructuringElements.test_white_tophat_white_pixel _____________________________ | |
self = <skimage.morphology.tests.test_grey.TestEccentricStructuringElements instance at 0x1128d4290> | |
def test_white_tophat_white_pixel(self): | |
> for s in self.selems: | |
E AttributeError: TestEccentricStructuringElements instance has no attribute 'selems' | |
skimage/morphology/tests/test_grey.py:103: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
____________________________ TestEccentricStructuringElements.test_black_tophat_black_pixel _____________________________ | |
self = <skimage.morphology.tests.test_grey.TestEccentricStructuringElements instance at 0x10df762d8> | |
def test_black_tophat_black_pixel(self): | |
> for s in self.selems: | |
E AttributeError: TestEccentricStructuringElements instance has no attribute 'selems' | |
skimage/morphology/tests/test_grey.py:108: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
____________________________ TestEccentricStructuringElements.test_white_tophat_black_pixel _____________________________ | |
self = <skimage.morphology.tests.test_grey.TestEccentricStructuringElements instance at 0x10dfbe518> | |
def test_white_tophat_black_pixel(self): | |
> for s in self.selems: | |
E AttributeError: TestEccentricStructuringElements instance has no attribute 'selems' | |
skimage/morphology/tests/test_grey.py:113: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
____________________________ TestEccentricStructuringElements.test_black_tophat_white_pixel _____________________________ | |
self = <skimage.morphology.tests.test_grey.TestEccentricStructuringElements instance at 0x10df7dc20> | |
def test_black_tophat_white_pixel(self): | |
> for s in self.selems: | |
E AttributeError: TestEccentricStructuringElements instance has no attribute 'selems' | |
skimage/morphology/tests/test_grey.py:118: AttributeError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
____________________________________________________ test_rect_tool _____________________________________________________ | |
args = (), kwargs = {} | |
original_units_registry = {<type 'datetime.time'>: <pandas.tseries.converter.TimeConverter object at 0x10a755650>, <type 'datetime.datetime'>: <...ct at 0x10a755690>, <type 'numpy.datetime64'>: <pandas.tseries.converter.DatetimeConverter object at 0x11493ed90>, ...} | |
original_settings = {'agg.path.chunksize': 0, 'animation.avconv_args': [], 'animation.avconv_path': 'avconv', 'animation.bitrate': -1, ...} | |
@functools.wraps(func) | |
def wrapped_function(*args, **kwargs): | |
original_units_registry = matplotlib.units.registry.copy() | |
original_settings = mpl.rcParams.copy() | |
try: | |
> func(*args, **kwargs) | |
/sw/lib/python2.7/site-packages/matplotlib/testing/decorators.py:118: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/sw/lib/python2.7/site-packages/numpy/testing/decorators.py:146: in skipper_func | |
return f(*args, **kwargs) | |
skimage/viewer/tests/test_tools.py:150: in test_rect_tool | |
assert_equal(tool.geometry, [120, 150, 120, 150]) | |
/sw/lib/python2.7/site-packages/numpy/testing/utils.py:290: in assert_equal | |
assert_equal(actual[k], desired[k], 'item=%r\n%s' % (k, err_msg), verbose) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 100, desired = 120, err_msg = 'item=0\n', verbose = True | |
def assert_equal(actual,desired,err_msg='',verbose=True): | |
""" | |
Raises an AssertionError if two objects are not equal. | |
Given two objects (scalars, lists, tuples, dictionaries or numpy arrays), | |
check that all elements of these objects are equal. An exception is raised | |
at the first conflicting values. | |
Parameters | |
---------- | |
actual : array_like | |
The object to check. | |
desired : array_like | |
The expected object. | |
err_msg : str, optional | |
The error message to be printed in case of failure. | |
verbose : bool, optional | |
If True, the conflicting values are appended to the error message. | |
Raises | |
------ | |
AssertionError | |
If actual and desired are not equal. | |
Examples | |
-------- | |
>>> np.testing.assert_equal([4,5], [4,6]) | |
... | |
<type 'exceptions.AssertionError'>: | |
Items are not equal: | |
item=1 | |
ACTUAL: 5 | |
DESIRED: 6 | |
""" | |
if isinstance(desired, dict): | |
if not isinstance(actual, dict): | |
raise AssertionError(repr(type(actual))) | |
assert_equal(len(actual), len(desired), err_msg, verbose) | |
for k, i in desired.items(): | |
if k not in actual: | |
raise AssertionError(repr(k)) | |
assert_equal(actual[k], desired[k], 'key=%r\n%s' % (k, err_msg), verbose) | |
return | |
if isinstance(desired, (list, tuple)) and isinstance(actual, (list, tuple)): | |
assert_equal(len(actual), len(desired), err_msg, verbose) | |
for k in range(len(desired)): | |
assert_equal(actual[k], desired[k], 'item=%r\n%s' % (k, err_msg), verbose) | |
return | |
from numpy.core import ndarray, isscalar, signbit | |
from numpy.lib import iscomplexobj, real, imag | |
if isinstance(actual, ndarray) or isinstance(desired, ndarray): | |
return assert_array_equal(actual, desired, err_msg, verbose) | |
msg = build_err_msg([actual, desired], err_msg, verbose=verbose) | |
# Handle complex numbers: separate into real/imag to handle | |
# nan/inf/negative zero correctly | |
# XXX: catch ValueError for subclasses of ndarray where iscomplex fail | |
try: | |
usecomplex = iscomplexobj(actual) or iscomplexobj(desired) | |
except ValueError: | |
usecomplex = False | |
if usecomplex: | |
if iscomplexobj(actual): | |
actualr = real(actual) | |
actuali = imag(actual) | |
else: | |
actualr = actual | |
actuali = 0 | |
if iscomplexobj(desired): | |
desiredr = real(desired) | |
desiredi = imag(desired) | |
else: | |
desiredr = desired | |
desiredi = 0 | |
try: | |
assert_equal(actualr, desiredr) | |
assert_equal(actuali, desiredi) | |
except AssertionError: | |
raise AssertionError(msg) | |
# Inf/nan/negative zero handling | |
try: | |
# isscalar test to check cases such as [np.nan] != np.nan | |
if isscalar(desired) != isscalar(actual): | |
raise AssertionError(msg) | |
# If one of desired/actual is not finite, handle it specially here: | |
# check that both are nan if any is a nan, and test for equality | |
# otherwise | |
if not (gisfinite(desired) and gisfinite(actual)): | |
isdesnan = gisnan(desired) | |
isactnan = gisnan(actual) | |
if isdesnan or isactnan: | |
if not (isdesnan and isactnan): | |
raise AssertionError(msg) | |
else: | |
if not desired == actual: | |
raise AssertionError(msg) | |
return | |
elif desired == 0 and actual == 0: | |
if not signbit(desired) == signbit(actual): | |
raise AssertionError(msg) | |
# If TypeError or ValueError raised while using isnan and co, just handle | |
# as before | |
except (TypeError, ValueError, NotImplementedError): | |
pass | |
# Explicitly use __eq__ for comparison, ticket #2552 | |
if not (desired == actual): | |
> raise AssertionError(msg) | |
E AssertionError: | |
E Items are not equal: | |
E item=0 | |
E | |
E ACTUAL: 100 | |
E DESIRED: 120 | |
/sw/lib/python2.7/site-packages/numpy/testing/utils.py:354: AssertionError | |
---------------------------------------------------- pytest-selenium ---------------------------------------------------- | |
==================== 33 failed, 1267 passed, 18 skipped, 5 pytest-warnings, 4 error in 91.26 seconds ==================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment