def test_interpolation_tetrahedral(self): """ Tests :func:`colour.algebra.interpolation.\ table_interpolation_tetrahedral` definition. """ prng = np.random.RandomState(4) V_xyz = random_triplet_generator(16, random_state=prng) np.testing.assert_almost_equal( table_interpolation_tetrahedral(V_xyz, LUT_TABLE), np.array([ [1.08039215, -0.02840092, 0.55855303], [0.52208945, 0.35297753, 0.13599555], [1.14373467, -0.00422138, 0.13413290], [0.71384967, 0.98420883, 0.57982724], [0.76771576, 0.46280975, 0.55106736], [0.20861663, 0.85077712, 0.57102264], [0.90398698, 0.72351675, 0.41151955], [0.03749453, 0.70226823, 0.52614254], [0.29626758, 0.21645072, 0.47615873], [0.46729624, 0.07494851, 0.68892548], [0.85907681, 0.67744258, 0.84410486], [0.24335535, 0.20896545, 0.21996717], [0.79244027, 0.66930773, 0.39213595], [1.08383608, 0.37985897, 0.49011919], [0.14683649, 0.43624903, 0.58706947], [0.61272658, 0.92799297, 0.29650424], ]))
def test_interpolation_tetrahedral(self): """ Tests :func:`colour.algebra.interpolation.\ table_interpolation_tetrahedral` definition. """ prng = np.random.RandomState(4) V_xyz = random_triplet_generator(16, random_state=prng) np.testing.assert_almost_equal( table_interpolation_tetrahedral(V_xyz, LUT_TABLE), np.array([ [1.08039215, -0.02840092, 0.55855303], [0.52208945, 0.35297753, 0.13599555], [1.14373467, -0.00422138, 0.13413290], [0.71384967, 0.98420883, 0.57982724], [0.76771576, 0.46280975, 0.55106736], [0.20861663, 0.85077712, 0.57102264], [0.90398698, 0.72351675, 0.41151955], [0.03749453, 0.70226823, 0.52614254], [0.29626758, 0.21645072, 0.47615873], [0.46729624, 0.07494851, 0.68892548], [0.85907681, 0.67744258, 0.84410486], [0.24335535, 0.20896545, 0.21996717], [0.79244027, 0.66930773, 0.39213595], [1.08383608, 0.37985897, 0.49011919], [0.14683649, 0.43624903, 0.58706947], [0.61272658, 0.92799297, 0.29650424], ]))
def test_interpolation_trilinear(self): """ Tests :func:`colour.algebra.interpolation.\ table_interpolation_trilinear` definition. """ prng = np.random.RandomState(4) V_xyz = random_triplet_generator(16, random_state=prng) np.testing.assert_almost_equal( table_interpolation_trilinear(V_xyz, LUT_TABLE), np.array([ [1.07937594, -0.02773926, 0.55498254], [0.53983424, 0.37099516, 0.13994561], [1.13449122, -0.00305380, 0.13792909], [0.73411897, 1.00141020, 0.59348239], [0.74066176, 0.44679540, 0.55030394], [0.20634750, 0.84797880, 0.55905579], [0.92348649, 0.73112515, 0.42362820], [0.03639248, 0.70357649, 0.52375041], [0.29215488, 0.19697840, 0.44603879], [0.47793470, 0.08696360, 0.70288463], [0.88883354, 0.68680856, 0.87404642], [0.21430977, 0.16796653, 0.19634247], [0.82118989, 0.69239283, 0.39932389], [1.06679072, 0.37974319, 0.49759377], [0.17856230, 0.44755467, 0.62045271], [0.59220355, 0.93136492, 0.30063692], ]))
def test_interpolation_trilinear(self): """ Tests :func:`colour.algebra.interpolation.\ table_interpolation_trilinear` definition. """ prng = np.random.RandomState(4) V_xyz = random_triplet_generator(16, random_state=prng) np.testing.assert_almost_equal( table_interpolation_trilinear(V_xyz, LUT_TABLE), np.array([ [1.07937594, -0.02773926, 0.55498254], [0.53983424, 0.37099516, 0.13994561], [1.13449122, -0.00305380, 0.13792909], [0.73411897, 1.00141020, 0.59348239], [0.74066176, 0.44679540, 0.55030394], [0.20634750, 0.84797880, 0.55905579], [0.92348649, 0.73112515, 0.42362820], [0.03639248, 0.70357649, 0.52375041], [0.29215488, 0.19697840, 0.44603879], [0.47793470, 0.08696360, 0.70288463], [0.88883354, 0.68680856, 0.87404642], [0.21430977, 0.16796653, 0.19634247], [0.82118989, 0.69239283, 0.39932389], [1.06679072, 0.37974319, 0.49759377], [0.17856230, 0.44755467, 0.62045271], [0.59220355, 0.93136492, 0.30063692], ]))
def test_random_triplet_generator(self): """ Tests :func:`colour.algebra.random.random_triplet_generator` definition. Notes ----- - The test is assuming that :func:`np.random.RandomState` definition will return the same sequence no matter which *OS* or *Python* version is used. There is however no formal promise about the *prng* sequence reproducibility of either *Python* or *Numpy* implementations, see :cite:`Laurent2012a`. """ prng = np.random.RandomState(4) np.testing.assert_almost_equal(RANDOM_TRIPLETS, random_triplet_generator( 10, random_state=prng), decimal=7) # TODO: Use "assertWarns" when dropping Python 2.7. random_triplet_generator(5.5, random_state=prng)
def test_random_triplet_generator(self): """ Tests :func:`colour.algebra.random.random_triplet_generator` definition. Notes ----- - The test is assuming that :func:`np.random.RandomState` definition will return the same sequence no matter which *OS* or *Python* version is used. There is however no formal promise about the *prng* sequence reproducibility of either *Python* or *Numpy* implementations, see :cite:`Laurent2012a`. """ prng = np.random.RandomState(4) np.testing.assert_almost_equal( RANDOM_TRIPLETS, random_triplet_generator(10, random_state=prng), decimal=7)
def test_random_triplet_generator(self): """ Tests :func:`colour.algebra.random.random_triplet_generator` definition. Notes ----- The test is assuming that :func:`np.random.RandomState` definition will return the same sequence no matter which *OS* or *Python* version is used. There is however no formal promise about the *prng* sequence reproducibility of either *Python or *Numpy* implementations: Laurent. (2012). Reproducibility of python pseudo-random numbers across systems and versions? Retrieved January 20, 2015, from http://stackoverflow.com/questions/8786084/reproducibility-of-python-pseudo-random-numbers-across-systems-and-versions # noqa """ prng = np.random.RandomState(4) np.testing.assert_almost_equal( RANDOM_TRIPLETS, np.array(list(random_triplet_generator(10, random_state=prng))), decimal=7)
def test_random_triplet_generator(self): """ Tests :func:`colour.algebra.random.random_triplet_generator` definition. Notes ----- The test is assuming that :func:`np.random.RandomState` definition will return the same sequence no matter which *OS* or *Python* version is used. There is however no formal promise about the *prng* sequence reproducibility of either *Python* or *Numpy* implementations: Laurent. (2012). Reproducibility of python pseudo-random numbers across systems and versions? Retrieved January 20, 2015, from http://stackoverflow.com/questions/8786084/\ reproducibility-of-python-pseudo-random-numbers-across-systems-and-versions """ prng = np.random.RandomState(4) np.testing.assert_almost_equal( RANDOM_TRIPLETS, np.array(list(random_triplet_generator(10, random_state=prng))), decimal=7)
def test_vertices_and_relative_coordinates(self): """ Tests :func:`colour.algebra.interpolation.\ vertices_and_relative_coordinates` definition. """ prng = np.random.RandomState(4) V_xyz = random_triplet_generator(4, random_state=prng) vertices, V_xyzr = vertices_and_relative_coordinates(V_xyz, LUT_TABLE) np.testing.assert_almost_equal( vertices, np.array([ [ [0.58919500, 0.58919500, 0.13916400], [0.33333300, 0.00000000, 0.33333300], [0.83331100, 0.83331100, 0.83331100], [0.79789400, -0.03541200, -0.03541200], ], [ [0.59460100, 0.59460100, 0.36958600], [0.39062300, 0.00000000, 0.78124600], [0.83331100, 0.83331100, 1.24996300], [0.75276700, -0.02847900, 0.36214400], ], [ [0.66343200, 0.93018800, 0.12992000], [0.41665500, 0.41665500, 0.41665500], [0.70710200, 1.11043500, 0.70710200], [0.63333300, 0.31666700, 0.00000000], ], [ [0.68274900, 0.99108200, 0.37441600], [0.41665500, 0.41665500, 0.83330800], [0.51971400, 0.74472900, 0.74472900], [0.73227800, 0.31562600, 0.31562600], ], [ [0.89131800, 0.61982300, 0.07683300], [0.75276700, -0.02847900, 0.36214400], [1.06561000, 0.64895700, 0.64895700], [1.19684100, -0.05311700, -0.05311700], ], [ [0.95000000, 0.63333300, 0.31666700], [0.66666700, 0.00000000, 0.66666700], [1.00000000, 0.66666700, 1.00000000], [1.16258800, -0.05037200, 0.35394800], ], [ [0.88379200, 0.88379200, 0.20874600], [0.73227800, 0.31562600, 0.31562600], [0.89460600, 0.89460600, 0.66959000], [1.03843900, 0.31089900, -0.05287000], ], [ [0.88919900, 0.88919900, 0.43916800], [0.66666700, 0.33333300, 0.66666700], [1.24996600, 1.24996600, 1.24996600], [1.13122500, 0.29792000, 0.29792000], ], ])) np.testing.assert_almost_equal( V_xyzr, np.array([ [0.90108952, 0.09318647, 0.75894709], [0.64169675, 0.64826849, 0.30437460], [0.91805308, 0.92882336, 0.33814877], [0.14444798, 0.01869077, 0.59305522], ]))
def test_vertices_and_relative_coordinates(self): """ Tests :func:`colour.algebra.interpolation.\ vertices_and_relative_coordinates` definition. """ prng = np.random.RandomState(4) V_xyz = random_triplet_generator(4, random_state=prng) vertices, V_xyzr = vertices_and_relative_coordinates(V_xyz, LUT_TABLE) np.testing.assert_almost_equal( vertices, np.array([ [ [0.58919500, 0.58919500, 0.13916400], [0.33333300, 0.00000000, 0.33333300], [0.83331100, 0.83331100, 0.83331100], [0.79789400, -0.03541200, -0.03541200], ], [ [0.59460100, 0.59460100, 0.36958600], [0.39062300, 0.00000000, 0.78124600], [0.83331100, 0.83331100, 1.24996300], [0.75276700, -0.02847900, 0.36214400], ], [ [0.66343200, 0.93018800, 0.12992000], [0.41665500, 0.41665500, 0.41665500], [0.70710200, 1.11043500, 0.70710200], [0.63333300, 0.31666700, 0.00000000], ], [ [0.68274900, 0.99108200, 0.37441600], [0.41665500, 0.41665500, 0.83330800], [0.51971400, 0.74472900, 0.74472900], [0.73227800, 0.31562600, 0.31562600], ], [ [0.89131800, 0.61982300, 0.07683300], [0.75276700, -0.02847900, 0.36214400], [1.06561000, 0.64895700, 0.64895700], [1.19684100, -0.05311700, -0.05311700], ], [ [0.95000000, 0.63333300, 0.31666700], [0.66666700, 0.00000000, 0.66666700], [1.00000000, 0.66666700, 1.00000000], [1.16258800, -0.05037200, 0.35394800], ], [ [0.88379200, 0.88379200, 0.20874600], [0.73227800, 0.31562600, 0.31562600], [0.89460600, 0.89460600, 0.66959000], [1.03843900, 0.31089900, -0.05287000], ], [ [0.88919900, 0.88919900, 0.43916800], [0.66666700, 0.33333300, 0.66666700], [1.24996600, 1.24996600, 1.24996600], [1.13122500, 0.29792000, 0.29792000], ], ])) np.testing.assert_almost_equal( V_xyzr, np.array([ [0.90108952, 0.09318647, 0.75894709], [0.64169675, 0.64826849, 0.30437460], [0.91805308, 0.92882336, 0.33814877], [0.14444798, 0.01869077, 0.59305522], ]))