def test_n_dimensional_cartesian_to_spherical(self): """ Tests :func:`colour.algebra.coordinates.transformations.\ cartesian_to_spherical` definition n-dimensional arrays support. """ vector_i = np.array([3, 1, 6]) vector_o = np.array([6.78232998, 1.08574654, 0.32175055]) np.testing.assert_almost_equal( cartesian_to_spherical(vector_i), vector_o, decimal=7) vector_i = np.tile(vector_i, (6, 1)) vector_o = np.tile(vector_o, (6, 1)) np.testing.assert_almost_equal( cartesian_to_spherical(vector_i), vector_o, decimal=7) vector_i = np.reshape(vector_i, (2, 3, 3)) vector_o = np.reshape(vector_o, (2, 3, 3)) np.testing.assert_almost_equal( cartesian_to_spherical(vector_i), vector_o, decimal=7)
def test_n_dimensional_cartesian_to_spherical(self): """ Tests :func:`colour.algebra.coordinates.transformations.\ cartesian_to_spherical` definition n-dimensional arrays support. """ a_i = np.array([3, 1, 6]) a_o = np.array([6.78232998, 1.08574654, 0.32175055]) np.testing.assert_almost_equal( cartesian_to_spherical(a_i), a_o, decimal=7) a_i = np.tile(a_i, (6, 1)) a_o = np.tile(a_o, (6, 1)) np.testing.assert_almost_equal( cartesian_to_spherical(a_i), a_o, decimal=7) a_i = np.reshape(a_i, (2, 3, 3)) a_o = np.reshape(a_o, (2, 3, 3)) np.testing.assert_almost_equal( cartesian_to_spherical(a_i), a_o, decimal=7)
def test_nan_cartesian_to_spherical(self): """ Tests :func:`colour.algebra.coordinates.transformations.\ cartesian_to_spherical` 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: a_i = np.array(case) cartesian_to_spherical(a_i)
def test_n_dimensional_cartesian_to_spherical(self): """ Tests :func:`colour.algebra.coordinates.transformations.\ cartesian_to_spherical` definition n-dimensional arrays support. """ a_i = np.array([3, 1, 6]) a_o = cartesian_to_spherical(a_i) a_i = np.tile(a_i, (6, 1)) a_o = np.tile(a_o, (6, 1)) np.testing.assert_almost_equal( cartesian_to_spherical(a_i), a_o, decimal=7) a_i = np.reshape(a_i, (2, 3, 3)) a_o = np.reshape(a_o, (2, 3, 3)) np.testing.assert_almost_equal( cartesian_to_spherical(a_i), a_o, decimal=7)
def test_cartesian_to_spherical(self): """ Tests :func:`colour.algebra.coordinates.transformations.cartesian_to_spherical` # noqa definition. """ np.testing.assert_almost_equal( cartesian_to_spherical((3, 1, 6)), np.array([6.78232998, 1.08574654, 0.32175055]), decimal=7) np.testing.assert_almost_equal( cartesian_to_spherical((-1, 9, 16)), np.array([18.38477631, 1.05578119, 1.68145355]), decimal=7) np.testing.assert_almost_equal( cartesian_to_spherical((6.3434, -0.9345, 18.5675)), np.array([19.64342307, 1.2382903, -0.1462664]), decimal=7)
def test_cartesian_to_spherical(self): """ Tests :func:`colour.algebra.coordinates.transformations.\ cartesian_to_spherical` definition. """ np.testing.assert_almost_equal( cartesian_to_spherical(np.array([3, 1, 6])), np.array([6.78232998, 0.48504979, 0.32175055]), decimal=7) np.testing.assert_almost_equal( cartesian_to_spherical(np.array([-1, 9, 16])), np.array([18.38477631, 0.51501513, 1.68145355]), decimal=7) np.testing.assert_almost_equal( cartesian_to_spherical(np.array([6.3434, -0.9345, 18.5675])), np.array([19.64342307, 0.33250603, -0.14626640]), decimal=7)