From 27fcb81f74d42de0bc6761a632aaca2897cf8d16 Mon Sep 17 00:00:00 2001 From: capitanbatata Date: Thu, 11 Sep 2014 18:23:55 +0200 Subject: [PATCH] Incorporated Stefan's comments. --- skimage/__init__.py | 1 - skimage/color/colorconv.py | 5 +-- skimage/color/tests/test_colorconv.py | 60 ++++++++++++++++----------- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/skimage/__init__.py b/skimage/__init__.py index 8b5d4056..59c80ed2 100644 --- a/skimage/__init__.py +++ b/skimage/__init__.py @@ -72,7 +72,6 @@ except ImportError: del version - try: _imp.find_module('nose') except ImportError: diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index 53642b1f..e8a95db8 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -56,7 +56,6 @@ from __future__ import division import numpy as np from scipy import linalg from ..util import dtype -from skimage._shared.utils import deprecated # Imported but unused. Remove? def guess_spatial_dimensions(image): @@ -396,7 +395,7 @@ def get_xyz_coords(illuminant, observer): return illuminants[illuminant][observer] except KeyError: raise ValueError("Unknown illuminant/observer combination\ - (\"{0}\", \"{1}\")".format(illuminant, observer)) + (\'{0}\', \'{1}\')".format(illuminant, observer)) # Haematoxylin-Eosin-DAB colorspace # From original Ruifrok's paper: A. C. Ruifrok and D. A. Johnston, @@ -765,7 +764,7 @@ def xyz2lab(xyz, illuminant="D65", observer="2"): ValueError If `xyz` is not a 3-D array of shape ``(.., ..,[ ..,] 3)``. ValueError - If either the illuminant or the observer angle are not supported or + If either the illuminant or the observer angle is unsupported or unknown. Notes diff --git a/skimage/color/tests/test_colorconv.py b/skimage/color/tests/test_colorconv.py index e9ac83ee..cf960f4e 100644 --- a/skimage/color/tests/test_colorconv.py +++ b/skimage/color/tests/test_colorconv.py @@ -227,50 +227,57 @@ class TestColorconv(TestCase): def test_rgb2grey_on_grey(self): rgb2grey(np.random.rand(5, 5)) - # test matrices for xyz2lab and lab2xyz generated using http://www.easyrgb.com/index.php?X=CALC + # test matrices for xyz2lab and lab2xyz generated using + # http://www.easyrgb.com/index.php?X=CALC # Note: easyrgb website displays xyz*100 def test_xyz2lab(self): assert_array_almost_equal(xyz2lab(self.xyz_array), self.lab_array, decimal=3) - ## Test the conversion with the rest of the illuminants. + # Test the conversion with the rest of the illuminants. for I in ["d50", "d55", "d65", "d75"]: for obs in ["2", "10"]: fname = "lab_array_{0}_{1}.npy".format(I, obs) - lab_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), 'data', fname)) + lab_array_I_obs = np.load( + os.path.join(os.path.dirname(__file__), 'data', fname)) assert_array_almost_equal(lab_array_I_obs, - xyz2lab(self.xyz_array, I, obs), decimal=2) + xyz2lab(self.xyz_array, I, obs), + decimal=2) for I in ["a", "e"]: fname = "lab_array_{0}_2.npy".format(I) - lab_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), 'data', fname)) + lab_array_I_obs = np.load( + os.path.join(os.path.dirname(__file__), 'data', fname)) assert_array_almost_equal(lab_array_I_obs, - xyz2lab(self.xyz_array, I, "2"), decimal=2) + xyz2lab(self.xyz_array, I, "2"), + decimal=2) def test_lab2xyz(self): assert_array_almost_equal(lab2xyz(self.lab_array), self.xyz_array, decimal=3) - ## Test the conversion with the rest of the illuminants. + # Test the conversion with the rest of the illuminants. for I in ["d50", "d55", "d65", "d75"]: for obs in ["2", "10"]: fname = "lab_array_{0}_{1}.npy".format(I, obs) - lab_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), 'data', fname)) - assert_array_almost_equal(lab2xyz(lab_array_I_obs, I, obs), + lab_array_I_obs = np.load( + os.path.join(os.path.dirname(__file__), 'data', fname)) + assert_array_almost_equal(lab2xyz(lab_array_I_obs, I, obs), self.xyz_array, decimal=3) for I in ["a", "e"]: fname = "lab_array_{0}_2.npy".format(I, obs) - lab_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), 'data', fname)) + lab_array_I_obs = np.load( + os.path.join(os.path.dirname(__file__), 'data', fname)) assert_array_almost_equal(lab2xyz(lab_array_I_obs, I, "2"), - self.xyz_array, decimal=3) + self.xyz_array, decimal=3) - ## And we include a call to test the exception handling in the code. + # And we include a call to test the exception handling in the code. try: xs = lab2xyz(lab_array_I_obs, "NaI", "2") # Not an illuminant except ValueError: pass - + try: - xs = lab2xyz(lab_array_I_obs, "d50", "42") # Not an observer degree + xs = lab2xyz(lab_array_I_obs, "d50", "42") # Not a degree except ValueError: pass @@ -304,36 +311,41 @@ class TestColorconv(TestCase): assert_array_almost_equal(xyz2luv(self.xyz_array), self.luv_array, decimal=3) - ## Test the conversion with the rest of the illuminants. + # Test the conversion with the rest of the illuminants. for I in ["d50", "d55", "d65", "d75"]: for obs in ["2", "10"]: fname = "luv_array_{0}_{1}.npy".format(I, obs) - luv_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), 'data', fname)) + luv_array_I_obs = np.load( + os.path.join(os.path.dirname(__file__), 'data', fname)) assert_array_almost_equal(luv_array_I_obs, - xyz2luv(self.xyz_array, I, obs), decimal=2) + xyz2luv(self.xyz_array, I, obs), + decimal=2) for I in ["a", "e"]: fname = "luv_array_{0}_2.npy".format(I) - luv_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), 'data', fname)) + luv_array_I_obs = np.load( + os.path.join(os.path.dirname(__file__), 'data', fname)) assert_array_almost_equal(luv_array_I_obs, - xyz2luv(self.xyz_array, I, "2"), decimal=2) - + xyz2luv(self.xyz_array, I, "2"), + decimal=2) def test_luv2xyz(self): assert_array_almost_equal(luv2xyz(self.luv_array), self.xyz_array, decimal=3) - ## Test the conversion with the rest of the illuminants. + # Test the conversion with the rest of the illuminants. for I in ["d50", "d55", "d65", "d75"]: for obs in ["2", "10"]: fname = "luv_array_{0}_{1}.npy".format(I, obs) - luv_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), 'data', fname)) + luv_array_I_obs = np.load( + os.path.join(os.path.dirname(__file__), 'data', fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, obs), self.xyz_array, decimal=3) for I in ["a", "e"]: fname = "luv_array_{0}_2.npy".format(I, obs) - luv_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), 'data', fname)) + luv_array_I_obs = np.load( + os.path.join(os.path.dirname(__file__), 'data', fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, "2"), - self.xyz_array, decimal=3) + self.xyz_array, decimal=3) def test_rgb2luv_brucelindbloom(self): """