コード例 #1
0
ファイル: test_learnernd.py プロジェクト: jhoofwijk/adaptive
def test_learnerND_curvature_inits_loss_depends_on_neighbors_correctly():
    loss = curvature_loss_function()
    assert loss.nth_neighbors == 1
    learner = LearnerND(ring_of_fire,
                        bounds=[(-1, 1), (-1, 1)],
                        loss_per_simplex=loss)
    assert learner.nth_neighbors == 1
コード例 #2
0
def test_learnerND_raises_if_too_many_neigbors():
    @uses_nth_neighbors(2)
    def loss(*args):
        return 0

    assert loss.nth_neighbors == 2
    with pytest.raises(NotImplementedError):
        LearnerND(ring_of_fire, bounds=[(-1, 1), (-1, 1)], loss_per_simplex=loss)
コード例 #3
0
ファイル: test_learnernd.py プロジェクト: jhoofwijk/adaptive
def test_learnerND_accepts_ConvexHull_as_input():
    triangle = ConvexHull([(0, 1), (2, 0), (0, 0)])
    learner = LearnerND(ring_of_fire, bounds=triangle)
    assert learner.nth_neighbors == 0
    assert np.allclose(learner._bbox, [(0, 2), (0, 1)])
コード例 #4
0
ファイル: test_learnernd.py プロジェクト: jhoofwijk/adaptive
def test_learnerND_inits_loss_depends_on_neighbors_correctly():
    learner = LearnerND(ring_of_fire, bounds=[(-1, 1), (-1, 1)])
    assert learner.nth_neighbors == 0