Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
13 changes: 13 additions & 0 deletions tests/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down