Skip to content

Use matched finite pairs for continuous verification moments - #580

Open
antonsoo wants to merge 1 commit into
pySTEPS:masterfrom
antonsoo:fix/continuous-score-finite-pairs
Open

antonsoo wants to merge 1 commit into
pySTEPS:masterfrom
antonsoo:fix/continuous-score-finite-pairs

Conversation

@antonsoo

Copy link
Copy Markdown

Continuous verification scores count finite forecast–observation pairs, but currently compute each variable's mean and variance using its own non-missing values. Unpaired observations can therefore change the correlation and regression scores:

import numpy as np
from pysteps.verification import det_cont_fct

pred = np.array([1., 2., 3., np.nan])
obs = np.array([1., 2., 3., 100.])
print(det_cont_fct(pred, obs, scores="corr_p"))
# currently {'corr_p': 0.019238330156554226}; expected {'corr_p': 1.0}

This masks both arrays with their joint finite mask before computing the moments. Counts, means, variances and covariance then describe the same samples. Tests cover missing values in either input, conditioning, axis reductions, streaming updates and input preservation.

I checked six lead times from each of the project's Finnish and Swiss radar examples. One Swiss forecast currently reports correlation 1.015110; the fix returns 0.853784, matching np.corrcoef on the valid pairs. All 48 failing direct/streaming moment checks now pass, while the finite-data and double-conditioned controls remain unchanged.

Validation: 813 tests pass in the full suite; both plugin tests pass when rerun after installing the missing pip dependency. One optional GDAL module is skipped. The focused tests and radar checks also pass on Python 3.11 / NumPy 1.26, and Black passes.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-24T03:04:29.141827Z e1e9423 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant