Skip to content

Commit

Permalink
Test sampling without bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
timmens committed Mar 16, 2023
1 parent 6bbf60a commit fca4c94
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/optimization/tranquilo/test_sample_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
SAMPLERS = ["random_interior", "random_hull", "optimal_hull"]


@pytest.mark.parametrize("sampler", SAMPLERS)
def test_samplers(sampler):
_sampler = get_sampler(sampler)
trustregion = Region(center=np.array([0.0, 0]), radius=1.5, bounds=None)
sample = _sampler(
trustregion=trustregion,
n_points=5,
rng=np.random.default_rng(1234),
)
assert len(sample) == 5
assert np.all(-1.5 <= sample)
assert np.all(sample <= 1.5)


@pytest.mark.parametrize("sampler", SAMPLERS)
def test_bounds_are_satisfied(sampler):
bounds = Bounds(lower=np.array([-2.0, -2.0]), upper=np.array([0.25, 0.5]))
Expand Down

0 comments on commit fca4c94

Please sign in to comment.