Example #1
0
 def test_fit_transform(self):
     X = np.random.randn(100, 2)
     tica = _internal_tica(1, 1)
     out = tica.fit_transform(X)
     np.testing.assert_array_almost_equal(
         out,
         api.tica(data=X, lag=1, dim=1).get_output()[0])
Example #2
0
    def test_constant_features(self):
        z = np.zeros((100, 10))
        o = np.ones((100, 10))
        tica_obj = _internal_tica(lag=10)
        tica_obj.partial_fit(z)
        with self.assertRaises(ZeroRankError):
            tica_obj.timescales
        with self.assertRaises(ZeroRankError):
            tica_obj.transform(z)
        tica_obj.partial_fit(o)
        try:
            tica_obj.timescales
            tica_obj.transform(z)
        except ZeroRankError:
            self.fail('ZeroRankError was raised unexpectedly.')

        tica_obj = _internal_tica(lag=10)
        with self.assertRaises(ZeroRankError):
            tica_obj.fit_transform(o)