From 402ee4e00a5e14a8a24db286a31e180318de166a Mon Sep 17 00:00:00 2001 From: Taksh Date: Sat, 11 Apr 2026 15:26:51 +0530 Subject: [PATCH] Fix test_vasopressor_units crashing on Series.contains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit \`test_vasopressor_units\` in \`mimic-iv/tests/test_medication.py\` checks whether any vasopressor row with a non-standard \`rateuom\` falls outside a whitelist of known-inspected \`hadm_id\`s, and raises a warning if so. The membership test is currently written as if (~df['hadm_id'].contains(hadm_id_list)).any(): but \`pandas.Series\` has no \`.contains()\` method — \`.contains()\` only lives on the \`.str\` accessor (for substring search against a single pattern, not membership in a list). Whenever the preceding \`gbq.read_gbq\` query returns any rows, this line raises \`AttributeError: 'Series' object has no attribute 'contains'\` and the test fails before it gets to the actual assertion on the following line. The correct pandas idiom for "row's hadm_id is in this list" is \`Series.isin(list)\`, which is what this code needs. Replace \`.contains(hadm_id_list)\` with \`.isin(hadm_id_list)\`; the outer \`~ ... .any()\` still expresses "any row outside the whitelist", matching the comment's stated intent. --- mimic-iv/tests/test_medication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mimic-iv/tests/test_medication.py b/mimic-iv/tests/test_medication.py index 4a42622b9..586e444a2 100644 --- a/mimic-iv/tests/test_medication.py +++ b/mimic-iv/tests/test_medication.py @@ -58,7 +58,7 @@ def test_vasopressor_units(dataset, project_id): """ df = gbq.read_gbq(query, project_id=project_id, dialect="standard") # if we find new uninspected rows, raise a warning. this will only happen when mimic-iv is updated. - if (~df['hadm_id'].contains(hadm_id_list)).any(): + if (~df['hadm_id'].isin(hadm_id_list)).any(): _LOGGER.warn(f"""New data found with non-standard unit. Inspect the data with this query: select *