Skip to content

Commit 3b06782

Browse files
matthew29tangcopybara-github
authored andcommitted
chore: Deflake test_evaluation unit test
PiperOrigin-RevId: 932610634
1 parent 1222795 commit 3b06782

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

tests/unit/vertexai/test_evaluation.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ def test_compute_pointwise_metrics(self, api_transport):
934934
scores = list(
935935
test_result.metrics_table["test_pointwise_metric/score"].to_list()
936936
)
937-
assert scores == [5, 4] or scores == [4, 5]
937+
assert sorted(scores) == [4, 5]
938938
assert list(
939939
test_result.metrics_table["test_pointwise_metric/explanation"].to_list()
940940
) == [
@@ -994,9 +994,9 @@ def _pointwise_side_effect(**kwargs):
994994
assert test_result.metrics_table["prompt"].equals(
995995
_TEST_EVAL_DATASET_ALL_INCLUDED["prompt"]
996996
)
997-
assert list(
998-
test_result.metrics_table["test_pointwise_metric_str/score"].to_list()
999-
) == [5, 4]
997+
assert sorted(
998+
list(test_result.metrics_table["test_pointwise_metric_str/score"].to_list())
999+
) == [4, 5]
10001000
assert list(
10011001
test_result.metrics_table["test_pointwise_metric_str/explanation"].to_list()
10021002
) == [
@@ -1049,9 +1049,9 @@ def test_compute_pointwise_metrics_metric_prompt_template_example(
10491049
"summarization_quality/explanation",
10501050
]
10511051
)
1052-
assert list(
1053-
test_result.metrics_table["summarization_quality/score"].to_list()
1054-
) == [5, 4]
1052+
assert sorted(
1053+
list(test_result.metrics_table["summarization_quality/score"].to_list())
1054+
) == [4, 5]
10551055
assert list(
10561056
test_result.metrics_table["summarization_quality/explanation"].to_list()
10571057
) == [
@@ -1166,9 +1166,9 @@ def _summarization_side_effect(**kwargs):
11661166
"source",
11671167
]
11681168
)
1169-
assert list(
1170-
test_result.metrics_table["summarization_quality/score"].to_list()
1171-
) == [5, 4]
1169+
assert sorted(
1170+
list(test_result.metrics_table["summarization_quality/score"].to_list())
1171+
) == [4, 5]
11721172
assert list(
11731173
test_result.metrics_table["summarization_quality/explanation"].to_list()
11741174
) == [
@@ -1595,9 +1595,9 @@ def test_compute_multiple_metrics(self, api_transport):
15951595
== 0.5
15961596
)
15971597

1598-
assert list(
1599-
test_result.metrics_table["summarization_quality/score"].to_list()
1600-
) == [5, 4]
1598+
assert sorted(
1599+
list(test_result.metrics_table["summarization_quality/score"].to_list())
1600+
) == [4, 5]
16011601
assert list(
16021602
test_result.metrics_table["summarization_quality/explanation"].to_list()
16031603
) == [
@@ -1884,7 +1884,9 @@ def test_runnable_response_eval_with_runnable_inference(self, api_transport):
18841884
"coherence/explanation",
18851885
]
18861886
)
1887-
assert list(test_result.metrics_table["coherence/score"].to_list()) == [5, 4]
1887+
assert sorted(
1888+
list(test_result.metrics_table["coherence/score"].to_list())
1889+
) == [4, 5]
18881890
assert list(test_result.metrics_table["coherence/explanation"].to_list()) == [
18891891
"explanation",
18901892
"explanation",

0 commit comments

Comments
 (0)