Пример #1
0
def test_samples_errors(rng):
    samples = rng.random_sample(size=(12, 2))
    with pytest.raises(ValidationError):
        dists.Samples(samples).sample(11, 2)
    with pytest.raises(ValidationError):
        dists.Samples(samples).sample(12, 1)
    with pytest.raises(ValidationError):
        dists.Samples(samples).sample(12)

    samples = rng.random_sample(size=12)
    with pytest.raises(ValidationError):
        dists.Samples(samples).sample(12, 2)
Пример #2
0
def test_samples_list(samples):
    d = dists.Samples(samples)
    shape = np.array(samples).shape
    dims = None if len(shape) == 1 else shape[1]
    assert np.allclose(d.sample(shape[0], dims), samples)
Пример #3
0
def test_samples(shape, rng):
    samples = rng.random_sample(size=shape)
    d = dists.Samples(samples)
    dims = None if len(shape) == 1 else shape[1]
    assert np.allclose(d.sample(shape[0], dims), samples)