✨ `spatial.distance.{c,p}dist`: metric-specific overloads #2392
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.34) × (1 − Review Confidence (0.89)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.34 · 131 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.85 · 4 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.292
Real PR Conversation Timeline
5 items
nit: This alias is only used once (in _Metric), so let's inline it
nit: I see multiple tests targeting a single overload, which seems a bit redundant; one type-test per overload is fine.
Also (not a nit this time), seeing as rejecting invalid kwargs is the whole point of #404, we should probably add some some rejection tests, e.g.
# pyrefly: ignore [no-matching-overload]
cdist(_f64_2d, _f64_2d, "euclidean", p=3) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
# pyrefly: ignore [no-matching-overload]
cdist(_f64_2d, _f64_2d, "correlation", centered=False) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
# pyrefly: ignore [no-matching-overload]
cdist(_f64_2d, _f64_2d, "seuclidean", w=_f64_1d) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
# pyrefly: ignore [no-matching-overload]
cdist(_f64_2d, _f64_2d, "jensenshannon", w=_f64_1d) # type: ignore[call-overload] # pyright: ignore[reportArgumentType, reportCallIssue]
Also (not a nit this time), seeing as rejecting invalid kwargs is the whole point of https://github.com/scipy/scipy-stubs/issues/404, we should probably add some some rejection tests, e.g.
hmm, i agree 👍 , initially i wrote 2 negative tests, but then i was not sure if i need to add these more, so i removed
i'll update with this , Thanks for the review :)
jorenham
Aniketsy
Fixes #404
In this PR we're adding separate overloads so that each metric only accepts the keyword arguments that actually work at runtime:
wonlyminkowskiacceptspandwseuclideanacceptsVonly, and it must be 1-dmahalanobisacceptsVIonlycorrelationacceptsw, andcenteredwhenwis also givenjensenshannonaccepts no extra keyword arguments