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)
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)
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)