def test_n_dimensional_whiteness_CIE2004(self): """ Tests :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition n_dimensional arrays support. """ xy = np.array([0.3167, 0.3334]) Y = 100 xy_n = np.array([0.3139, 0.3311]) WT = np.array([93.8500000, -1.30500000]) np.testing.assert_almost_equal(whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7) xy = np.tile(xy, (6, 1)) WT = np.tile(WT, (6, 1)) np.testing.assert_almost_equal(whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7) Y = np.tile(Y, 6) xy_n = np.tile(xy_n, (6, 1)) np.testing.assert_almost_equal(whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7) xy = np.reshape(xy, (2, 3, 2)) Y = np.reshape(Y, (2, 3)) xy_n = np.reshape(xy_n, (2, 3, 2)) WT = np.reshape(WT, (2, 3, 2)) np.testing.assert_almost_equal(whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7)
def test_whiteness_CIE2004(self): """ Tests :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition. """ np.testing.assert_almost_equal( whiteness_CIE2004(np.array([0.3139, 0.3311]), 100, np.array([0.3139, 0.3311])), np.array([100.00000000, 0.00000000]), decimal=7) np.testing.assert_almost_equal( whiteness_CIE2004(np.array([0.3500, 0.3334]), 100, np.array([0.3139, 0.3311])), np.array([67.21000000, -34.60500000]), decimal=7) np.testing.assert_almost_equal( whiteness_CIE2004(np.array([0.3334, 0.3334]), 100, np.array([0.3139, 0.3311])), np.array([80.49000000, -18.00500000]), decimal=7)
def test_nan_whiteness_CIE2004(self): """ Tests :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition nan support. """ cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=3)) for case in cases: xy = np.array(case[0:2]) Y = np.array(case[0]) xy_n = np.array(case[0:2]) whiteness_CIE2004(xy, Y, xy_n)
def test_domain_range_scale_whiteness_CIE2004(self): """ Tests :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition domain and range scale support. """ xy = np.array([0.3167, 0.3334]) Y = 100 xy_n = np.array([0.3139, 0.3311]) WT = whiteness_CIE2004(xy, Y, xy_n) d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_almost_equal(whiteness_CIE2004( xy, Y * factor, xy_n), WT * factor, decimal=7)
def test_n_dimensional_whiteness_CIE2004(self): """ Tests :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition n_dimensional arrays support. """ xy = np.array([0.3167, 0.3334]) Y = 100 xy_n = np.array([0.3139, 0.3311]) WT = np.array([93.8500000, -1.30500000]) np.testing.assert_almost_equal( whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7) xy = np.tile(xy, (6, 1)) WT = np.tile(WT, (6, 1)) np.testing.assert_almost_equal( whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7) Y = np.tile(Y, 6) xy_n = np.tile(xy_n, (6, 1)) np.testing.assert_almost_equal( whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7) xy = np.reshape(xy, (2, 3, 2)) Y = np.reshape(Y, (2, 3)) xy_n = np.reshape(xy_n, (2, 3, 2)) WT = np.reshape(WT, (2, 3, 2)) np.testing.assert_almost_equal( whiteness_CIE2004(xy, Y, xy_n), WT, decimal=7)