Skip to content

Commit

Permalink
Update tests/metrics/test_compute_average_precision.py
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Kerfoot <[email protected]>
Signed-off-by: YunLiu <[email protected]>
  • Loading branch information
KumoLiu and ericspod authored Feb 19, 2025
1 parent 35aca33 commit ccca17d
Showing 1 changed file with 16 additions and 32 deletions.
48 changes: 16 additions & 32 deletions tests/metrics/test_compute_average_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,24 @@
float("nan"),
]

ALL_TESTS = [
TEST_CASE_1,
TEST_CASE_2,
TEST_CASE_3,
TEST_CASE_4,
TEST_CASE_5,
TEST_CASE_6,
TEST_CASE_7,
TEST_CASE_8,
TEST_CASE_9,
TEST_CASE_10,
TEST_CASE_11,
TEST_CASE_12,
]

class TestComputeAveragePrecision(unittest.TestCase):

@parameterized.expand(
[
TEST_CASE_1,
TEST_CASE_2,
TEST_CASE_3,
TEST_CASE_4,
TEST_CASE_5,
TEST_CASE_6,
TEST_CASE_7,
TEST_CASE_8,
TEST_CASE_9,
TEST_CASE_10,
TEST_CASE_11,
TEST_CASE_12,
]
)
@parameterized.expand(ALL_TESTS)
def test_value(self, y_pred, y, softmax, to_onehot, average, expected_value):
y_pred_trans = Compose([ToTensor(), Activations(softmax=softmax)])
y_trans = Compose([ToTensor(), AsDiscrete(to_onehot=to_onehot)])
Expand All @@ -143,22 +142,7 @@ def test_value(self, y_pred, y, softmax, to_onehot, average, expected_value):
result = compute_average_precision(y_pred=y_pred, y=y, average=average)
np.testing.assert_allclose(expected_value, result, rtol=1e-5)

@parameterized.expand(
[
TEST_CASE_1,
TEST_CASE_2,
TEST_CASE_3,
TEST_CASE_4,
TEST_CASE_5,
TEST_CASE_6,
TEST_CASE_7,
TEST_CASE_8,
TEST_CASE_9,
TEST_CASE_10,
TEST_CASE_11,
TEST_CASE_12,
]
)
@parameterized.expand(ALL_TESTS)
def test_class_value(self, y_pred, y, softmax, to_onehot, average, expected_value):
y_pred_trans = Compose([ToTensor(), Activations(softmax=softmax)])
y_trans = Compose([ToTensor(), AsDiscrete(to_onehot=to_onehot)])
Expand Down

0 comments on commit ccca17d

Please sign in to comment.