def test_pca_using_expected_num_dimensions(): data = [[-1, -1], [1, 1]] expected = numpy.matrix([[-1], [1]]) assert numpy.array_equal(preprocess.pca(data, 1), expected)
def test_pca_using_num_dimensions_func(): data = [[-1, -1], [1, 1]] expected = numpy.matrix([[-1], [1]]) def selection_func(eigen_values): return [i for i, v in enumerate(eigen_values) if v > 1] assert numpy.array_equal( preprocess.pca(data, select_dimensions_func=selection_func), expected)
def test_pca_both_expected_and_func(): with pytest.raises(ValueError): preprocess.pca([], 1, lambda x: [0])
def test_pca_no_expected_or_func(): with pytest.raises(ValueError): preprocess.pca([], None, None)