What's wrong
_score_array picks predict_affinity_score when the model has one, otherwise falls
back to model.predict_proba(X)[:, 1]. Every score invocation in
tests/test_cli.py scores whatever train just produced with the default
--model (DonorPropensityModel), which has predict_affinity_score — so the
fallback line never runs. Two of the four CLI-documented models,
LapsePredictor (predict_lapse_score, no predict_affinity_score) and
PlannedGivingIntentScorer (predict_intent_score, no predict_affinity_score),
would hit that fallback, but nothing ever trains-then-scores either of them.
Where
| File |
Locate with |
philanthropy/cli.py |
grep -n "_score_array" -A 3 philanthropy/cli.py |
What to change
No source change — this is test-only.
- Open
tests/test_cli.py and look at test_cli_train_accepts_every_documented_model
(locate with grep -n "def test_cli_train_accepts_every_documented_model" tests/test_cli.py)
for the existing --model parametrization style.
- Add a new test that runs
train with --model PlannedGivingIntentScorer (or
LapsePredictor), then score against the same data, and asserts the score
column exists and has no NaN values — proving the predict_proba fallback path
ran end to end without an AttributeError.
Tests to add or extend
- File:
tests/test_cli.py
- Add:
test_cli_score_falls_back_to_predict_proba_without_affinity_score
Done when
python -m pytest tests/test_cli.py --cov=philanthropy.cli --cov-report=term-missing -q
philanthropy/cli.py reads 100% covered with an empty Missing column.
What's wrong
_score_arraypickspredict_affinity_scorewhen the model has one, otherwise fallsback to
model.predict_proba(X)[:, 1]. Everyscoreinvocation intests/test_cli.pyscores whatevertrainjust produced with the default--model(DonorPropensityModel), which haspredict_affinity_score— so thefallback line never runs. Two of the four CLI-documented models,
LapsePredictor(predict_lapse_score, nopredict_affinity_score) andPlannedGivingIntentScorer(predict_intent_score, nopredict_affinity_score),would hit that fallback, but nothing ever trains-then-scores either of them.
Where
philanthropy/cli.pygrep -n "_score_array" -A 3 philanthropy/cli.pyWhat to change
No source change — this is test-only.
tests/test_cli.pyand look attest_cli_train_accepts_every_documented_model(locate with
grep -n "def test_cli_train_accepts_every_documented_model" tests/test_cli.py)for the existing
--modelparametrization style.trainwith--model PlannedGivingIntentScorer(orLapsePredictor), thenscoreagainst the same data, and asserts thescorecolumn exists and has no
NaNvalues — proving thepredict_probafallback pathran end to end without an
AttributeError.Tests to add or extend
tests/test_cli.pytest_cli_score_falls_back_to_predict_proba_without_affinity_scoreDone when
philanthropy/cli.pyreads 100% covered with an emptyMissingcolumn.