Skip to content

test: cli's _score_array never exercises the plain predict_proba fallback branch #53

Description

@shivamlalakiya

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.

  1. 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.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    beginnerNo fundraising domain knowledge neededeasySmall, well-scoped, single-file changegood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions