Exemplo n.º 1
0
 def test_bootstrap_replicate_01(self):
     np.random.seed(42)
     matrix = np.random.uniform(-1, 1, 9).reshape(3, 3)
     weights = np.ones((3, 1)) / 3
     ss = Subspaces()
     wei = ss._bootstrap_replicate(matrix, weights)[1]
     np.testing.assert_array_almost_equal(weights, wei)
Exemplo n.º 2
0
 def test_partition_05(self):
     np.random.seed(42)
     matrix = np.random.uniform(-1, 1, 9).reshape(3, 3)
     ss = Subspaces()
     ss.evects = matrix
     with self.assertRaises(ValueError):
         ss.partition(dim=4)
Exemplo n.º 3
0
 def test_partition_01(self):
     np.random.seed(42)
     matrix = np.random.uniform(-1, 1, 9).reshape(3, 3)
     ss = Subspaces(dim=2)
     ss.evects = matrix
     ss._partition()
     np.testing.assert_array_almost_equal(matrix[:, :2], ss.W1)
Exemplo n.º 4
0
 def test_partition_03(self):
     np.random.seed(42)
     matrix = np.random.uniform(-1, 1, 9).reshape(3, 3)
     ss = Subspaces(dim=2.0)
     ss.evects = matrix
     with self.assertRaises(TypeError):
         ss._partition()
Exemplo n.º 5
0
 def test_plot_sufficient_summary(self):
     ss = Subspaces(dim=1)
     inputs = np.diag(np.ones(3))
     outputs = np.ones(3).reshape(3, 1)
     with self.assertRaises(ValueError):
         ss.plot_sufficient_summary(inputs,
                                    outputs,
                                    figsize=(7, 7),
                                    title='Sufficient_summary_plots')
Exemplo n.º 6
0
 def test_bootstrap_replicate_02(self):
     np.random.seed(42)
     matrix = np.random.uniform(-1, 1, 9).reshape(3, 3)
     weights = np.ones((3, 1)) / 3
     ss = Subspaces(dim=1)
     mat = ss._bootstrap_replicate(matrix, weights)[0]
     true_matrix = np.array([[-0.88383278, 0.73235229, 0.20223002],
                             [0.19731697, -0.68796272, -0.68801096],
                             [-0.25091976, 0.90142861, 0.46398788]])
     np.testing.assert_array_almost_equal(true_matrix, mat)
Exemplo n.º 7
0
 def test_plot_eigenvectors(self):
     ss = Subspaces(dim=1)
     with self.assertRaises(ValueError):
         ss.plot_eigenvectors(n_evects=2, title='Eigenvectors')
Exemplo n.º 8
0
 def test_init_evals_br(self):
     ss = Subspaces()
     self.assertIsNone(ss.evals_br)
Exemplo n.º 9
0
 def test_init_W1(self):
     ss = Subspaces(dim=1)
     self.assertIsNone(ss.W1)
Exemplo n.º 10
0
 def test_transform(self):
     ss = Subspaces(dim=1)
     with self.assertRaises(NotImplementedError):
         ss.transform(42)
Exemplo n.º 11
0
 def test_inverse_transform(self):
     ss = Subspaces(dim=1)
     with self.assertRaises(NotImplementedError):
         ss.inverse_transform(10, 10)
Exemplo n.º 12
0
 def test_init_dim(self):
     ss = Subspaces(dim=1)
     self.assertEqual(ss.dim, 1)
Exemplo n.º 13
0
 def test_fit(self):
     ss = Subspaces(dim=1)
     with self.assertRaises(NotImplementedError):
         ss.fit()
Exemplo n.º 14
0
 def test_init_evects(self):
     ss = Subspaces(dim=1)
     self.assertIsNone(ss.evects)
Exemplo n.º 15
0
 def test_init_subs_br(self):
     ss = Subspaces(dim=1)
     self.assertIsNone(ss.subs_br)
Exemplo n.º 16
0
 def test_init_W2(self):
     ss = Subspaces()
     self.assertIsNone(ss.W2)
Exemplo n.º 17
0
 def test_init_dim(self):
     ss = Subspaces()
     self.assertIsNone(ss.dim)
Exemplo n.º 18
0
 def test_plot_eigenvalues(self):
     ss = Subspaces(dim=1)
     with self.assertRaises(ValueError):
         ss.plot_eigenvalues(figsize=(7, 7), title='Eigenvalues')
Exemplo n.º 19
0
 def test_init_cov_matrix(self):
     ss = Subspaces()
     self.assertIsNone(ss.cov_matrix)
Exemplo n.º 20
0
 def test_compute(self):
     ss = Subspaces()
     with self.assertRaises(NotImplementedError):
         ss.compute()
Exemplo n.º 21
0
 def test_backward(self):
     ss = Subspaces()
     with self.assertRaises(NotImplementedError):
         ss.backward(10, 10)
Exemplo n.º 22
0
 def test_forward(self):
     ss = Subspaces()
     with self.assertRaises(NotImplementedError):
         ss.forward(42)