def test_snapshot_with_without_rowvar(): """Tests the snapshot method, with and without rowvar, works correctly.""" np.random.seed(1) data = np.random.normal(size=(10, 50)) pc1 = PrincipalComponents(data) pc2 = PrincipalComponents(data.T, rowvar=True) pc1._snapshot() pc2._snapshot() check_cols_match_except_sign(pc1._eigvec, pc2._eigvec)
def test_em_vs_snapshot_pc_rowvar_false(): """Tests that EM and snapshot agree.""" np.random.seed(1) data = np.random.normal(size=(10, 50)) pc1 = PrincipalComponents(data) pc2 = PrincipalComponents(data) pc1._snapshot() pc2._expectation_maximization(5) check_cols_match_except_sign(pc1._eigvec[:, :5], pc2._eigvec)
def test_snapshot_vs_direct_pc_rowvar_false(): """Tests that snapshot and direct agree.""" np.random.seed(1) data = np.random.normal(size=(10, 50)) pc1 = PrincipalComponents(data) pc2 = PrincipalComponents(data) pc1._direct() pc2._snapshot() check_cols_match_except_sign(pc1._eigvec[:, :4], pc2._eigvec[:, :4])