Exemple #1
0
 def test_ilr_basis_one_dimension_error(self):
     table = np.array([[1., 10.], [1.14141414, 9.90909091],
                       [1.28282828, 9.81818182], [1.42424242, 9.72727273],
                       [1.56565657, 9.63636364]])
     basis = np.array([0.80442968, 0.19557032])
     with self.assertRaises(ValueError):
         ilr(closure(table), basis=basis)
Exemple #2
0
    def test_ilr_basis_isomorphism(self):
        # tests to make sure that the isomorphism holds
        # with the introduction of the basis.
        basis = np.array([[0.80442968, 0.19557032]])
        table = np.array([[
            np.log(1 / 10) * np.sqrt(1 / 2),
            np.log(1.14141414 / 9.90909091) * np.sqrt(1 / 2),
            np.log(1.28282828 / 9.81818182) * np.sqrt(1 / 2),
            np.log(1.42424242 / 9.72727273) * np.sqrt(1 / 2),
            np.log(1.56565657 / 9.63636364) * np.sqrt(1 / 2)
        ]]).T
        res = ilr(ilr_inv(table, basis=basis), basis=basis)
        npt.assert_allclose(res, table.squeeze())

        table = np.array([[1., 10.], [1.14141414, 9.90909091],
                          [1.28282828, 9.81818182], [1.42424242, 9.72727273],
                          [1.56565657, 9.63636364]])

        res = ilr_inv(np.atleast_2d(ilr(closure(table), basis=basis)).T,
                      basis=basis)
        npt.assert_allclose(res, closure(table.squeeze()))
Exemple #3
0
    def test_ilr_inv(self):
        mat = closure(self.cdata7)
        npt.assert_array_almost_equal(ilr_inv(ilr(mat)), mat)

        npt.assert_allclose(ilr_inv(np.identity(3)),
                            self.ortho1,
                            rtol=1e-04,
                            atol=1e-06)

        with self.assertRaises(ValueError):
            ilr_inv(self.cdata1, basis=self.cdata1)

        # make sure that inplace modification is not occurring
        ilr_inv(self.cdata1)
        npt.assert_allclose(self.cdata1, np.array([[2, 2, 6], [4, 4, 2]]))
Exemple #4
0
    def test_ilr_basis(self):
        table = np.array([[1., 10.], [1.14141414, 9.90909091],
                          [1.28282828, 9.81818182], [1.42424242, 9.72727273],
                          [1.56565657, 9.63636364]])
        basis = np.array([[0.80442968, 0.19557032]])
        res = ilr(closure(table), basis=basis)
        exp = np.array([
            np.log(1 / 10) * np.sqrt(1 / 2),
            np.log(1.14141414 / 9.90909091) * np.sqrt(1 / 2),
            np.log(1.28282828 / 9.81818182) * np.sqrt(1 / 2),
            np.log(1.42424242 / 9.72727273) * np.sqrt(1 / 2),
            np.log(1.56565657 / 9.63636364) * np.sqrt(1 / 2)
        ])

        npt.assert_allclose(res, exp)
Exemple #5
0
    def test_ilr(self):
        mat = closure(self.cdata7)
        npt.assert_array_almost_equal(ilr(mat),
                                      np.array([0.70710678, 0.40824829]))

        # Should give same result as inner
        npt.assert_allclose(ilr(closure(self.ortho1)),
                            np.identity(3),
                            rtol=1e-04,
                            atol=1e-06)

        with self.assertRaises(ValueError):
            ilr(closure(self.cdata1), basis=self.cdata1)

        # make sure that inplace modification is not occurring
        ilr(closure(self.cdata1))
        npt.assert_allclose(self.cdata1, np.array([[2, 2, 6], [4, 4, 2]]))