From f2d5b109e90dde5ba50a5717428d91a85d85003f Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Thu, 13 Sep 2012 22:15:14 -0400 Subject: [PATCH 1/2] Add `assert_greater` compatibility function. Fix tests to work with nose < 1.1.3. Compatibility functions borrowed from scikit-learn. --- skimage/_shared/testing.py | 28 +++++++++++++++++++ .../segmentation/tests/test_felzenszwalb.py | 2 +- skimage/segmentation/tests/test_quickshift.py | 3 +- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 skimage/_shared/testing.py diff --git a/skimage/_shared/testing.py b/skimage/_shared/testing.py new file mode 100644 index 00000000..a5270125 --- /dev/null +++ b/skimage/_shared/testing.py @@ -0,0 +1,28 @@ +"""Testing utilities.""" + +# Copyright (c) 2011 Pietro Berkes +# License: Simplified BSD + +def _assert_less(a, b, msg=None): + message = "%r is not lower than %r" % (a, b) + if msg is not None: + message += ": " + msg + assert a < b, message + + +def _assert_greater(a, b, msg=None): + message = "%r is not greater than %r" % (a, b) + if msg is not None: + message += ": " + msg + assert a > b, message + + +try: + from nose.tools import assert_less +except ImportError: + assert_less = _assert_less + +try: + from nose.tools import assert_greater +except ImportError: + assert_greater = _assert_greater diff --git a/skimage/segmentation/tests/test_felzenszwalb.py b/skimage/segmentation/tests/test_felzenszwalb.py index 8a7abfc4..9fd0b018 100644 --- a/skimage/segmentation/tests/test_felzenszwalb.py +++ b/skimage/segmentation/tests/test_felzenszwalb.py @@ -1,6 +1,6 @@ import numpy as np from numpy.testing import assert_equal, assert_array_equal -from nose.tools import assert_greater +from skimage._shared.testing import assert_greater from skimage.segmentation import felzenszwalb diff --git a/skimage/segmentation/tests/test_quickshift.py b/skimage/segmentation/tests/test_quickshift.py index eebcaf0d..d43d7559 100644 --- a/skimage/segmentation/tests/test_quickshift.py +++ b/skimage/segmentation/tests/test_quickshift.py @@ -1,6 +1,7 @@ import numpy as np from numpy.testing import assert_equal, assert_array_equal -from nose.tools import assert_true, assert_greater +from nose.tools import assert_true +from skimage._shared.testing import assert_greater from skimage.segmentation import quickshift From 2cbe2e1f20a6ac2d7de247a7ec960bb99d34a182 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 16 Sep 2012 15:44:52 -0400 Subject: [PATCH 2/2] DOC: Fix attribution for testing function The testing functions taken from scikit-learn were in a file with a copyright assigned to Pietro, but Andreas was resposible for the specific lines that were copied. --- CONTRIBUTORS.txt | 2 +- skimage/_shared/testing.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 4abe9256..5f375c39 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -73,7 +73,7 @@ From whom we borrowed the example generation tools. - Andreas Mueller - Example data set loader. + Example data set loader. Nosetest compatibility functions. Quickshift image segmentation, Felzenszwalbs fast graph based segmentation. - Yaroslav Halchenko diff --git a/skimage/_shared/testing.py b/skimage/_shared/testing.py index a5270125..eab83a56 100644 --- a/skimage/_shared/testing.py +++ b/skimage/_shared/testing.py @@ -1,7 +1,5 @@ """Testing utilities.""" -# Copyright (c) 2011 Pietro Berkes -# License: Simplified BSD def _assert_less(a, b, msg=None): message = "%r is not lower than %r" % (a, b)