What's wrong
PlannedGivingIntentScorer.predict_intent_score short-circuits to
np.zeros(proba.shape[0]) when predict_proba returns fewer than two columns
(the single-class-seen-at-fit case). This is the same shape of guard as the one
fixed for PropensityScorer.predict_proba in #50, but in a different class and
method — nothing in tests/test_planned_giving.py fits on single-label data, so
this branch has never run.
Where
| File |
Locate with |
philanthropy/models/_planned_giving.py |
grep -n "proba.shape\[1\] < 2" philanthropy/models/_planned_giving.py |
What to change
No source change — this is test-only.
- Open
tests/test_planned_giving.py and look at the existing
predict_intent_score test (locate with
grep -n "def test.*intent_score" tests/test_planned_giving.py) for fixture
style.
- Add a test that fits
PlannedGivingIntentScorer on a y containing only one
label, then calls predict_intent_score and asserts every score is 0.0.
Tests to add or extend
- File:
tests/test_planned_giving.py
- Add:
test_predict_intent_score_single_class_returns_zeros
Done when
python -m pytest tests/test_planned_giving.py --cov=philanthropy.models._planned_giving --cov-report=term-missing -q
philanthropy/models/_planned_giving.py reads 100% covered with an empty
Missing column.
What's wrong
PlannedGivingIntentScorer.predict_intent_scoreshort-circuits tonp.zeros(proba.shape[0])whenpredict_probareturns fewer than two columns(the single-class-seen-at-fit case). This is the same shape of guard as the one
fixed for
PropensityScorer.predict_probain #50, but in a different class andmethod — nothing in
tests/test_planned_giving.pyfits on single-label data, sothis branch has never run.
Where
philanthropy/models/_planned_giving.pygrep -n "proba.shape\[1\] < 2" philanthropy/models/_planned_giving.pyWhat to change
No source change — this is test-only.
tests/test_planned_giving.pyand look at the existingpredict_intent_scoretest (locate withgrep -n "def test.*intent_score" tests/test_planned_giving.py) for fixturestyle.
PlannedGivingIntentScoreron aycontaining only onelabel, then calls
predict_intent_scoreand asserts every score is0.0.Tests to add or extend
tests/test_planned_giving.pytest_predict_intent_score_single_class_returns_zerosDone when
philanthropy/models/_planned_giving.pyreads 100% covered with an emptyMissingcolumn.