def test_n_dimensional_complementary_wavelength(self): """ Tests :func:`colour.colorimetry.dominant.complementary_wavelength` definition n-dimensional arrays support. """ xy = np.array([0.54369557, 0.32107944]) xy_n = D65 wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r, xy_wl_r, xy_cwl_r = (np.array(492.0), np.array([0.03647950, 0.33847127]), np.array([0.03647950, 0.33847127])) np.testing.assert_almost_equal(wl, wl_r) np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r = np.tile(wl_r, 6) xy_wl_r = np.tile(xy_wl_r, (6, 1)) xy_cwl_r = np.tile(xy_cwl_r, (6, 1)) np.testing.assert_almost_equal(wl, wl_r) np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r = np.reshape(wl_r, (2, 3)) xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2)) xy_cwl_r = np.reshape(xy_cwl_r, (2, 3, 2)) np.testing.assert_almost_equal(wl, wl_r) np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7)
def test_complementary_wavelength(self): """ Test :func:`colour.colorimetry.dominant.complementary_wavelength` definition. """ xy = np.array([0.54369557, 0.32107944]) xy_n = self._xy_D65 wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n) self.assertEqual(wl, np.array(492.0)) np.testing.assert_almost_equal( xy_wl, np.array([0.03647950, 0.33847127]), decimal=7 ) np.testing.assert_almost_equal( xy_cwl, np.array([0.03647950, 0.33847127]), decimal=7 ) xy = np.array([0.37605506, 0.24452225]) i_wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n) self.assertEqual(i_wl, np.array(509.0)) np.testing.assert_almost_equal( xy_wl, np.array([0.01040962, 0.73207453]), decimal=7 ) np.testing.assert_almost_equal( xy_cwl, np.array([0.01040962, 0.73207453]), decimal=7 )
def test_complementary_wavelength(self): """ Tests :func:`colour.colorimetry.dominant.complementary_wavelength` definition. """ xy = np.array([0.54369557, 0.32107944]) xy_n = D65 wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) self.assertEqual(wl, np.array(492.0)) np.testing.assert_almost_equal( xy_wl, np.array([0.03647950, 0.33847127]), decimal=7) np.testing.assert_almost_equal( xy_cwl, np.array([0.03647950, 0.33847127]), decimal=7) xy = np.array([0.37605506, 0.24452225]) i_wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) self.assertEqual(i_wl, np.array(509.0)) np.testing.assert_almost_equal( xy_wl, np.array([0.01040962, 0.73207453]), decimal=7) np.testing.assert_almost_equal( xy_cwl, np.array([0.01040962, 0.73207453]), decimal=7)
def test_n_dimensional_complementary_wavelength(self): """ Tests :func:`colour.colorimetry.dominant.complementary_wavelength` definition n-dimensional arrays support. """ xy = np.array([0.54369557, 0.32107944]) xy_n = D65 wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r, xy_wl_r, xy_cwl_r = (np.array(492.0), np.array([0.03647950, 0.33847127]), np.array([0.03647950, 0.33847127])) np.testing.assert_almost_equal(wl, wl_r) np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r = np.tile(wl_r, 6) xy_wl_r = np.tile(xy_wl_r, (6, 1)) xy_cwl_r = np.tile(xy_cwl_r, (6, 1)) np.testing.assert_almost_equal(wl, wl_r) np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7) xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r = np.reshape(wl_r, (2, 3)) xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2)) xy_cwl_r = np.reshape(xy_cwl_r, (2, 3, 2)) np.testing.assert_almost_equal(wl, wl_r) np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r, decimal=7)
def test_complementary_wavelength(self): """ Tests :func:`colour.colorimetry.dominant.complementary_wavelength` definition. """ xy = np.array([0.26415, 0.37770]) xy_n = D65 wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) self.assertEqual(wl, -504) np.testing.assert_almost_equal( xy_wl, np.array([0.48974944, 0.15140355]), decimal=7) np.testing.assert_almost_equal( xy_cwl, np.array([0.00369694, 0.63895775]), decimal=7) xy = np.array([0.35000, 0.25000]) i_wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) self.assertEqual(i_wl, 520) np.testing.assert_almost_equal( xy_wl, np.array([0.07435534, 0.83380505]), decimal=7) np.testing.assert_almost_equal( xy_cwl, np.array([0.07435534, 0.83380505]), decimal=7)
def test_n_dimensional_complementary_wavelength(self): """ Tests :func:`colour.colorimetry.dominant.complementary_wavelength` definition n-dimensional arrays support. """ xy = np.array([0.26415, 0.37770]) xy_n = D65 wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r, xy_wl_r, xy_cwl_r = (-504, np.array([0.48974944, 0.15140355]), np.array([0.00369694, 0.63895775])) np.testing.assert_almost_equal(wl, wl_r, decimal=7) np.testing.assert_almost_equal(xy_wl, xy_wl_r) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r) xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r = np.tile(wl_r, 6) xy_wl_r = np.tile(xy_wl_r, (6, 1)) xy_cwl_r = np.tile(xy_cwl_r, (6, 1)) np.testing.assert_almost_equal(wl, wl_r, decimal=7) np.testing.assert_almost_equal(xy_wl, xy_wl_r) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r) xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r = np.reshape(wl_r, (2, 3)) xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2)) xy_cwl_r = np.reshape(xy_cwl_r, (2, 3, 2)) np.testing.assert_almost_equal(wl, wl_r, decimal=7) np.testing.assert_almost_equal(xy_wl, xy_wl_r) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r)
def test_complementary_wavelength(self): """ Tests :func:`colour.colorimetry.dominant.complementary_wavelength` definition. """ xy = np.array([0.26415, 0.37770]) xy_n = D65 wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) self.assertEqual(wl, -504) np.testing.assert_almost_equal(xy_wl, np.array([0.48974944, 0.15140355]), decimal=7) np.testing.assert_almost_equal(xy_cwl, np.array([0.00369694, 0.63895775]), decimal=7) xy = np.array([0.35000, 0.25000]) i_wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) self.assertEqual(i_wl, 520) np.testing.assert_almost_equal(xy_wl, np.array([0.07435534, 0.83380505]), decimal=7) np.testing.assert_almost_equal(xy_cwl, np.array([0.07435534, 0.83380505]), decimal=7)
def test_nan_complementary_wavelength(self): """ Tests :func:`colour.colorimetry.dominant.complementary_wavelength` definition nan support. """ cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=2)) for case in cases: try: complementary_wavelength(case, case, CIE_2_1931_CMFS) except ValueError: pass
def test_n_dimensional_complementary_wavelength(self): """ Tests :func:`colour.colorimetry.dominant.complementary_wavelength` definition n-dimensional arrays support. """ xy = np.array([0.26415, 0.37770]) xy_n = D65 wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r, xy_wl_r, xy_cwl_r = (-504, np.array([0.48974944, 0.15140355]), np.array([0.00369694, 0.63895775])) np.testing.assert_almost_equal( wl, wl_r, decimal=7) np.testing.assert_almost_equal(xy_wl, xy_wl_r) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r) xy = np.tile(xy, (6, 1)) xy_n = np.tile(xy_n, (6, 1)) wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r = np.tile(wl_r, 6) xy_wl_r = np.tile(xy_wl_r, (6, 1)) xy_cwl_r = np.tile(xy_cwl_r, (6, 1)) np.testing.assert_almost_equal( wl, wl_r, decimal=7) np.testing.assert_almost_equal(xy_wl, xy_wl_r) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r) xy = np.reshape(xy, (2, 3, 2)) xy_n = np.reshape(xy_n, (2, 3, 2)) wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n, CIE_2_1931_CMFS) wl_r = np.reshape(wl_r, (2, 3)) xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2)) xy_cwl_r = np.reshape(xy_cwl_r, (2, 3, 2)) np.testing.assert_almost_equal( wl, wl_r, decimal=7) np.testing.assert_almost_equal(xy_wl, xy_wl_r) np.testing.assert_almost_equal(xy_cwl, xy_cwl_r)