From 5d226ec77f4d402e7a1ca93a70ae0714ec2eba9f Mon Sep 17 00:00:00 2001 From: solarsys Date: Thu, 1 Oct 2026 23:35:56 -0400 Subject: [PATCH] Make the ATC-3 drug recommendation test order-insensitive test_mimic3_demo_drug_recommendation_maps_ndc_to_atc3 asserted the exact order ["A10B", "C03C"] for one visit's drugs. Those codes come from prescriptions on the same day (MIMIC-III records dates only), and the order of same-timestamp events follows the row order of the cached event table, which the parallel build does not keep stable. The test therefore failed intermittently in CI (e.g. ['C03C', 'A10B'] != ['A10B', 'C03C']). "drugs" is a multilabel target, so check the codes, each exactly once, with assertCountEqual instead of their order. Co-Authored-By: Claude Opus 5.5 --- tests/core/test_drug_recommendation_atc3.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/core/test_drug_recommendation_atc3.py b/tests/core/test_drug_recommendation_atc3.py index 1adb4937f..47c62912e 100644 --- a/tests/core/test_drug_recommendation_atc3.py +++ b/tests/core/test_drug_recommendation_atc3.py @@ -102,7 +102,9 @@ def _assert_atc3_samples(self, samples, first_hadm_id, second_hadm_id): first_sample = by_visit[first_hadm_id] second_sample = by_visit[second_hadm_id] - self.assertEqual(first_sample["drugs"], ["A10B", "C03C"]) + # "drugs" is a multilabel target: check the codes (each once), not the + # order of same-day prescriptions. + self.assertCountEqual(first_sample["drugs"], ["A10B", "C03C"]) self.assertEqual(second_sample["drugs"], ["N02B"]) self.assertNotIn("1111", first_sample["drugs"]) self.assertNotIn("2222", first_sample["drugs"])