Ejemplo n.º 1
0
def test_whiten_error():
    rng = np.random.RandomState(123)
    m, n = 500, 4

    X = rng.randn(m, n)

    with pytest.raises(ValueError, match="method must be one of"):
        Y, W = whiten_data(X, method="uniform")
Ejemplo n.º 2
0
def test_whiten(method, centre):
    rng = np.random.RandomState(123)
    m, n = 500, 4

    X = rng.randn(m, n)

    Y, W = whiten_data(X, centre=centre, method=method)
    cov = Y.T @ Y
    cov *= n / np.trace(cov)

    # Y.T @ Y should be approximately an identity matrix
    np.testing.assert_allclose(cov, np.eye(n), atol=1e-6)