Пример #1
0
def test_cov_shape(random_process: randprocs.RandomProcess, args0: np.ndarray):
    """Test whether the covariance of the random process has the correct shape."""
    n = args0.shape[0]
    if random_process.output_dim == 1:
        assert (random_process.cov(args0).shape == (n, n)
                or random_process.cov(args0).ndim < 2)
    else:
        assert random_process.cov(args0).shape == (
            n,
            n,
            random_process.output_dim,
            random_process.output_dim,
        )
Пример #2
0
def test_rp_mean_cov_evaluated_matches_rv_mean_cov(
        random_process: randprocs.RandomProcess,
        random_state: np.random.RandomState):
    """Check whether the evaluated mean and covariance function of a random process is
    equivalent to the mean and covariance of the evaluated random process as a random
    variable."""
    x = random_state.normal(size=(10, random_process.input_dim))

    np.testing.assert_allclose(
        random_process(x).mean,
        random_process.mean(x),
        err_msg=f"Mean of evaluated {repr(random_process)} does not match the "
        f"random process mean function evaluated.",
    )

    np.testing.assert_allclose(
        random_process(x).cov,
        random_process.cov(x),
        err_msg=
        f"Covariance of evaluated {repr(random_process)} does not match the "
        f"random process mean function evaluated.",
    )