def test_perturb_inv(self):
        pmat = perturb_inv(closure(self.cdata1), closure([.1, .1, .1]))
        imat = perturb(closure(self.cdata1), closure([10, 10, 10]))
        npt.assert_allclose(pmat, imat)
        pmat = perturb_inv(closure(self.cdata1), closure([1, 1, 1]))
        npt.assert_allclose(pmat, closure([[.2, .2, .6], [.4, .4, .2]]))
        pmat = perturb_inv(closure(self.cdata5), closure([.1, .1, .1]))
        imat = perturb(closure(self.cdata1), closure([10, 10, 10]))
        npt.assert_allclose(pmat, imat)

        with self.assertRaises(ValueError):
            perturb_inv(closure(self.cdata1), self.bad1)

        # make sure that inplace modification is not occurring
        perturb_inv(self.cdata2, [1, 2, 3])
        npt.assert_allclose(self.cdata2, np.array([2, 2, 6]))
Beispiel #2
0
    def test_perturb_inv(self):
        pmat = perturb_inv(closure(self.data1),
                           closure([.1, .1, .1]))
        imat = perturb(closure(self.data1),
                       closure([10, 10, 10]))
        npt.assert_allclose(pmat, imat)
        pmat = perturb_inv(closure(self.data1),
                           closure([1, 1, 1]))
        npt.assert_allclose(pmat,
                            closure([[.2, .2, .6],
                                     [.4, .4, .2]]))
        pmat = perturb_inv(closure(self.data5),
                           closure([.1, .1, .1]))
        imat = perturb(closure(self.data1), closure([10, 10, 10]))
        npt.assert_allclose(pmat, imat)

        with self.assertRaises(ValueError):
            perturb_inv(closure(self.data1), self.bad1)

        # make sure that inplace modification is not occurring
        perturb_inv(self.data2, [1, 2, 3])
        npt.assert_allclose(self.data2, np.array([2, 2, 6]))