Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
CONTRIBUTORS.md. Implemented as `scripts/check_credit.sh`, wired into
`ci.yml` on `pull_request` events only; failures surface as inline
`::error::` annotations on the Files tab. Closes #113.
- Regression coverage ensuring `MovesManagementClassifier.fit` preserves
DataFrame column names in `feature_names_in_`. Closes #54.
### Fixed
- `CRMCleaner.transform` no longer silently corrupts complex amounts into
wrong finite floats: cells holding actual `complex` values are masked to
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ contribution. Code, docs, tests, and review all count.
regression test pinning the `donor_id` error that `RFMTransformer.fit` raises
for non-DataFrame input
([#139](https://github.com/PhilanthroPy-Project/PhilanthroPy/pull/139)).
- [@stoppo22](https://github.com/stoppo22): added DataFrame feature-name
coverage for `MovesManagementClassifier.fit`
([#146](https://github.com/PhilanthroPy-Project/PhilanthroPy/pull/146)).

## Getting listed

Expand Down
19 changes: 19 additions & 0 deletions tests/test_moves.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import numpy as np
import pandas as pd
import pytest

from philanthropy.models import MovesManagementClassifier
Expand Down Expand Up @@ -55,3 +56,21 @@ def test_action_priority_summary_counts_every_donor(stage_Xy):
summary = clf.action_priority(X)["portfolio_summary"]
assert sum(summary.values()) == 30
assert set(summary) <= set(_STAGES)


def test_fit_with_dataframe_sets_feature_names_in():
X = pd.DataFrame(
np.random.default_rng(0).random((30, 5)),
columns=["age", "income", "donations", "engagement", "years_active"],
)
y = np.asarray(_STAGES * 10)

clf = MovesManagementClassifier(max_iter=10, random_state=0).fit(X, y)

np.testing.assert_array_equal(
clf.feature_names_in_,
np.array(
["age", "income", "donations", "engagement", "years_active"],
dtype=object,
),
)