diff --git a/CHANGELOG.md b/CHANGELOG.md index 212c341..e943565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) ## [Unreleased] +### Added +- Tests for `EncounterTransformer` non-DataFrame `encounter_df` TypeError and + `_validate_X` early-return for array input. Closes #152. + ### Fixed - `GratefulPatientFeaturizer` now reports one fallback `general` service line per known donor when the encounter table omits the service-line column. diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a571edf..4950100 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -76,3 +76,4 @@ too; say so in the PR and it stays out. Not sure where to start? See [CONTRIBUTING.md](CONTRIBUTING.md) and the [good first issues](https://github.com/PhilanthroPy-Project/PhilanthroPy/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). +- [@haas26p-ctrl](https://github.com/haas26p-ctrl): added EncounterTransformer validation-branch tests ([#152](https://github.com/PhilanthroPy-Project/PhilanthroPy/issues/152)). diff --git a/tests/test_preprocessing.py b/tests/test_preprocessing.py index 9e763c8..be5a43c 100755 --- a/tests/test_preprocessing.py +++ b/tests/test_preprocessing.py @@ -453,6 +453,19 @@ def test_all_nan_discharge_warns(self, gift_df_with_ids): t.fit(gift_df_with_ids) assert any(isinstance(warning.category, type(UserWarning)) for warning in w) + def test_encounter_transformer_rejects_non_dataframe_encounter_df(self, gift_df_with_ids): + """List-of-dicts encounter_df must raise TypeError from _validate_encounter_df.""" + t = EncounterTransformer( + encounter_df=[{"donor_id": 1, "discharge_date": "2022-01-01"}] + ) + with pytest.raises(TypeError, match="must be a pd.DataFrame"): + t.fit(gift_df_with_ids) + + def test_encounter_transformer_validate_x_passes_arrays_through(self, encounter_df): + """Array X goes through _validate_X early-return; public fit succeeds.""" + t = EncounterTransformer(encounter_df=encounter_df) + assert t.fit(np.zeros((2, 3))) is t + # --------------------------------------------------------------------------- # # EncounterRecencyTransformer: parameter validation and input shapes