def test_nonunique_observe():
    # Simply re-observing a non-unique values returns the cached result
    pbounds = {'p1': (0, 1), 'p2': (1, 100)}
    space = TargetSpace(target_func, pbounds)
    x = [0, 0]
    y = 0
    space.add_observation(x, y)

    with pytest.raises(KeyError):
        space.add_observation(x, y)

    space._assert_internal_invariants(fast=False)
def test_nonunique_add():
    # Adding non-unique values throws a KeyError
    pbounds = {'p1': (0, 1), 'p2': (1, 100)}
    space = TargetSpace(target_func, pbounds)
    x = [0, 0]
    y = 0
    space.add_observation(x, y)

    with pytest.raises(KeyError):
        space.add_observation(x, y)

    space._assert_internal_invariants(fast=False)