Skip to content

Fix skipna handling in bucket extrema - #761

Open
Don-Yin wants to merge 1 commit into
pytroll:mainfrom
Don-Yin:fix-bucket-extrema-skipna
Open

Don-Yin wants to merge 1 commit into
pytroll:mainfrom
Don-Yin:fix-bucket-extrema-skipna

Conversation

@Don-Yin

@Don-Yin Don-Yin commented Oct 22, 2026

Copy link
Copy Markdown

A bucket containing [NaN, -7, 3] currently returns NaN from get_max and get_abs_max with skipna=True, while get_min(..., skipna=False) returns -7 instead of propagating the NaN.

This keeps NaNs behind valid values in the descending sort and reuses the existing missing-bin mask for skipna=False. Empty and all-NaN buckets keep their current behavior; no fill-value semantics are changed.

The new cases cover all three methods, both skipna settings, three chunk sizes, Dask arrays and xarray wrappers, and verify that constructing the result stays lazy. They also check valid, empty, all-NaN, and out-of-area samples.

Measured regression results before and after the fix

Each row contains six measured cases: three chunk sizes × two input wrappers. On the unchanged base, 18 of the 36 new cases fail; with the fix, all 36 pass.

Tests run:

  • pytest -q pyresample/test/test_bucket.py: 77 passed.

  • pre-commit run --files pyresample/bucket/__init__.py pyresample/test/test_bucket.py: Ruff, whitespace checks, Bandit, mypy and isort passed.

  • git diff --check: passed.

  • Tests added

  • Tests passed

  • Fully documented: restores the existing documented skipna behavior.

Signed-off-by: Don Yin <Don_Yin@outlook.com>
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