Skip to content

Commit ccca17d

Browse files
KumoLiuericspod
andauthored
Update tests/metrics/test_compute_average_precision.py
Co-authored-by: Eric Kerfoot <[email protected]> Signed-off-by: YunLiu <[email protected]>
1 parent 35aca33 commit ccca17d

File tree

1 file changed

+16
-32
lines changed

1 file changed

+16
-32
lines changed

tests/metrics/test_compute_average_precision.py

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,24 @@
116116
float("nan"),
117117
]
118118

119+
ALL_TESTS = [
120+
TEST_CASE_1,
121+
TEST_CASE_2,
122+
TEST_CASE_3,
123+
TEST_CASE_4,
124+
TEST_CASE_5,
125+
TEST_CASE_6,
126+
TEST_CASE_7,
127+
TEST_CASE_8,
128+
TEST_CASE_9,
129+
TEST_CASE_10,
130+
TEST_CASE_11,
131+
TEST_CASE_12,
132+
]
119133

120134
class TestComputeAveragePrecision(unittest.TestCase):
121135

122-
@parameterized.expand(
123-
[
124-
TEST_CASE_1,
125-
TEST_CASE_2,
126-
TEST_CASE_3,
127-
TEST_CASE_4,
128-
TEST_CASE_5,
129-
TEST_CASE_6,
130-
TEST_CASE_7,
131-
TEST_CASE_8,
132-
TEST_CASE_9,
133-
TEST_CASE_10,
134-
TEST_CASE_11,
135-
TEST_CASE_12,
136-
]
137-
)
136+
@parameterized.expand(ALL_TESTS)
138137
def test_value(self, y_pred, y, softmax, to_onehot, average, expected_value):
139138
y_pred_trans = Compose([ToTensor(), Activations(softmax=softmax)])
140139
y_trans = Compose([ToTensor(), AsDiscrete(to_onehot=to_onehot)])
@@ -143,22 +142,7 @@ def test_value(self, y_pred, y, softmax, to_onehot, average, expected_value):
143142
result = compute_average_precision(y_pred=y_pred, y=y, average=average)
144143
np.testing.assert_allclose(expected_value, result, rtol=1e-5)
145144

146-
@parameterized.expand(
147-
[
148-
TEST_CASE_1,
149-
TEST_CASE_2,
150-
TEST_CASE_3,
151-
TEST_CASE_4,
152-
TEST_CASE_5,
153-
TEST_CASE_6,
154-
TEST_CASE_7,
155-
TEST_CASE_8,
156-
TEST_CASE_9,
157-
TEST_CASE_10,
158-
TEST_CASE_11,
159-
TEST_CASE_12,
160-
]
161-
)
145+
@parameterized.expand(ALL_TESTS)
162146
def test_class_value(self, y_pred, y, softmax, to_onehot, average, expected_value):
163147
y_pred_trans = Compose([ToTensor(), Activations(softmax=softmax)])
164148
y_trans = Compose([ToTensor(), AsDiscrete(to_onehot=to_onehot)])

0 commit comments

Comments
 (0)