mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
pytest.approx with absolute eps
This commit is contained in:
parent
5b598bd1d5
commit
232e953b14
|
@ -360,25 +360,25 @@ def test_beam_overfitting_IO():
|
|||
head_scores = head_scores[0]
|
||||
label_scores = label_scores[0]
|
||||
# test label annotations: 0=nsubj, 2=dobj, 3=punct
|
||||
assert label_scores[(0, "nsubj")] == pytest.approx(1.0, eps)
|
||||
assert label_scores[(0, "dobj")] == pytest.approx(0.0, eps)
|
||||
assert label_scores[(0, "punct")] == pytest.approx(0.0, eps)
|
||||
assert label_scores[(2, "nsubj")] == pytest.approx(0.0, eps)
|
||||
assert label_scores[(2, "dobj")] == pytest.approx(1.0, eps)
|
||||
assert label_scores[(2, "punct")] == pytest.approx(0.0, eps)
|
||||
assert label_scores[(3, "nsubj")] == pytest.approx(0.0, eps)
|
||||
assert label_scores[(3, "dobj")] == pytest.approx(0.0, eps)
|
||||
assert label_scores[(3, "punct")] == pytest.approx(1.0, eps)
|
||||
assert label_scores[(0, "nsubj")] == pytest.approx(1.0, abs=eps)
|
||||
assert label_scores[(0, "dobj")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores[(0, "punct")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores[(2, "nsubj")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores[(2, "dobj")] == pytest.approx(1.0, abs=eps)
|
||||
assert label_scores[(2, "punct")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores[(3, "nsubj")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores[(3, "dobj")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores[(3, "punct")] == pytest.approx(1.0, abs=eps)
|
||||
# test head annotations: the root is token at index 1
|
||||
assert head_scores[(0, 0)] == pytest.approx(0.0, eps)
|
||||
assert head_scores[(0, 1)] == pytest.approx(1.0, eps)
|
||||
assert head_scores[(0, 2)] == pytest.approx(0.0, eps)
|
||||
assert head_scores[(2, 0)] == pytest.approx(0.0, eps)
|
||||
assert head_scores[(2, 1)] == pytest.approx(1.0, eps)
|
||||
assert head_scores[(2, 2)] == pytest.approx(0.0, eps)
|
||||
assert head_scores[(3, 0)] == pytest.approx(0.0, eps)
|
||||
assert head_scores[(3, 1)] == pytest.approx(1.0, eps)
|
||||
assert head_scores[(3, 2)] == pytest.approx(0.0, eps)
|
||||
assert head_scores[(0, 0)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores[(0, 1)] == pytest.approx(1.0, abs=eps)
|
||||
assert head_scores[(0, 2)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores[(2, 0)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores[(2, 1)] == pytest.approx(1.0, abs=eps)
|
||||
assert head_scores[(2, 2)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores[(3, 0)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores[(3, 1)] == pytest.approx(1.0, abs=eps)
|
||||
assert head_scores[(3, 2)] == pytest.approx(0.0, abs=eps)
|
||||
|
||||
# Also test the results are still the same after IO
|
||||
with make_tempdir() as tmp_dir:
|
||||
|
@ -392,21 +392,21 @@ def test_beam_overfitting_IO():
|
|||
head_scores2 = head_scores2[0]
|
||||
label_scores2 = label_scores2[0]
|
||||
# check the results again
|
||||
assert label_scores2[(0, "nsubj")] == pytest.approx(1.0, eps)
|
||||
assert label_scores2[(0, "dobj")] == pytest.approx(0.0, eps)
|
||||
assert label_scores2[(0, "punct")] == pytest.approx(0.0, eps)
|
||||
assert label_scores2[(2, "nsubj")] == pytest.approx(0.0, eps)
|
||||
assert label_scores2[(2, "dobj")] == pytest.approx(1.0, eps)
|
||||
assert label_scores2[(2, "punct")] == pytest.approx(0.0, eps)
|
||||
assert label_scores2[(3, "nsubj")] == pytest.approx(0.0, eps)
|
||||
assert label_scores2[(3, "dobj")] == pytest.approx(0.0, eps)
|
||||
assert label_scores2[(3, "punct")] == pytest.approx(1.0, eps)
|
||||
assert head_scores2[(0, 0)] == pytest.approx(0.0, eps)
|
||||
assert head_scores2[(0, 1)] == pytest.approx(1.0, eps)
|
||||
assert head_scores2[(0, 2)] == pytest.approx(0.0, eps)
|
||||
assert head_scores2[(2, 0)] == pytest.approx(0.0, eps)
|
||||
assert head_scores2[(2, 1)] == pytest.approx(1.0, eps)
|
||||
assert head_scores2[(2, 2)] == pytest.approx(0.0, eps)
|
||||
assert head_scores2[(3, 0)] == pytest.approx(0.0, eps)
|
||||
assert head_scores2[(3, 1)] == pytest.approx(1.0, eps)
|
||||
assert head_scores2[(3, 2)] == pytest.approx(0.0, eps)
|
||||
assert label_scores2[(0, "nsubj")] == pytest.approx(1.0, abs=eps)
|
||||
assert label_scores2[(0, "dobj")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores2[(0, "punct")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores2[(2, "nsubj")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores2[(2, "dobj")] == pytest.approx(1.0, abs=eps)
|
||||
assert label_scores2[(2, "punct")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores2[(3, "nsubj")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores2[(3, "dobj")] == pytest.approx(0.0, abs=eps)
|
||||
assert label_scores2[(3, "punct")] == pytest.approx(1.0, abs=eps)
|
||||
assert head_scores2[(0, 0)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores2[(0, 1)] == pytest.approx(1.0, abs=eps)
|
||||
assert head_scores2[(0, 2)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores2[(2, 0)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores2[(2, 1)] == pytest.approx(1.0, abs=eps)
|
||||
assert head_scores2[(2, 2)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores2[(3, 0)] == pytest.approx(0.0, abs=eps)
|
||||
assert head_scores2[(3, 1)] == pytest.approx(1.0, abs=eps)
|
||||
assert head_scores2[(3, 2)] == pytest.approx(0.0, abs=eps)
|
||||
|
|
Loading…
Reference in New Issue
Block a user