Skip to content

Commit

Permalink
Used pytest.approx for comparing floating point numbers in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitlal31 committed Mar 18, 2024
1 parent 422d765 commit c7ce29d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/components/rankers/test_metafield.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def test_reciprocal_rank_fusion(self):
]
output = ranker.run(documents=docs_before)
docs_after = output["documents"]
assert docs_after[0].score == 0.01626123744050767
assert docs_after[0].score == pytest.approx(0.016261, abs=1e-5)

@pytest.mark.parametrize("score", [-1, 2, 1.3, 2.1])
def test_linear_score_raises_warning_if_doc_wrong_score(self, score, caplog):
Expand Down Expand Up @@ -235,4 +235,4 @@ def test_different_ranking_mode_for_init_vs_run(self):

output = ranker.run(documents=docs_before, ranking_mode="reciprocal_rank_fusion")
docs_after = output["documents"]
assert docs_after[0].score == 0.01626123744050767
assert docs_after[0].score == pytest.approx(0.016261, abs=1e-5)

0 comments on commit c7ce29d

Please sign in to comment.