What's wrong
MovesManagementClassifier.fit branches on whether X has a .columns
attribute, setting feature_names_in_ from the column names when it does.
Every test in tests/test_moves.py fits with a bare ndarray, so the
pd.DataFrame branch never runs and feature_names_in_ is never exercised via
a real DataFrame input.
Where
| File |
Locate with |
philanthropy/models/_moves.py |
grep -n 'hasattr(X, "columns")' philanthropy/models/_moves.py |
What to change
No source change — this is test-only.
- Open
tests/test_moves.py and find the existing fit-related fixture/test
(locate with grep -n "def test_" tests/test_moves.py | head) for the style
used to build X/y.
- Add a test that fits
MovesManagementClassifier on a pandas.DataFrame with
named columns and asserts feature_names_in_ equals those column names
(np.array([...], dtype=object)).
Tests to add or extend
- File:
tests/test_moves.py
- Add:
test_fit_with_dataframe_sets_feature_names_in
Done when
python -m pytest tests/test_moves.py --cov=philanthropy.models._moves --cov-report=term-missing -q
philanthropy/models/_moves.py reads 100% covered with an empty Missing column.
What's wrong
MovesManagementClassifier.fitbranches on whetherXhas a.columnsattribute, setting
feature_names_in_from the column names when it does.Every test in
tests/test_moves.pyfits with a barendarray, so thepd.DataFramebranch never runs andfeature_names_in_is never exercised viaa real DataFrame input.
Where
philanthropy/models/_moves.pygrep -n 'hasattr(X, "columns")' philanthropy/models/_moves.pyWhat to change
No source change — this is test-only.
tests/test_moves.pyand find the existingfit-related fixture/test(locate with
grep -n "def test_" tests/test_moves.py | head) for the styleused to build
X/y.MovesManagementClassifieron apandas.DataFramewithnamed columns and asserts
feature_names_in_equals those column names(
np.array([...], dtype=object)).Tests to add or extend
tests/test_moves.pytest_fit_with_dataframe_sets_feature_names_inDone when
philanthropy/models/_moves.pyreads 100% covered with an emptyMissingcolumn.