Skip to content

Fix LongitudeMaskingCompositor ignoring a limit of 0 degrees - #3536

Open
rmz-oz wants to merge 2 commits into
pytroll:mainfrom
rmz-oz:fix-lonmask-zero-limits
Open

rmz-oz wants to merge 2 commits into
pytroll:mainfrom
rmz-oz:fix-lonmask-zero-limits

Conversation

@rmz-oz

@rmz-oz rmz-oz commented Dec 3, 2026

Copy link
Copy Markdown

LongitudeMaskingCompositor replaced lon_min=0 with -180 and lon_max=0 with 180 because the defaults were set with if not ..., so a 0 to 90E box kept everything from 180W to 90E. Now only None gets the default. Added 0 degree cases to the existing masking test.

  • Tests added
  • Add your name to AUTHORS.md if not there already

@djhoese djhoese left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Thanks for the fix. If you're using an AI could you replace the test class with a pytest test function that uses parametrize over all these cases? If not using an AI, don't worry about it.

@rmz-oz

rmz-oz commented Dec 4, 2026

Copy link
Copy Markdown
Author

Done, it's one parametrized test function now. The two 0 degree cases still fail without the fix.

Comment thread satpy/composites/mask.py
class LongitudeMaskingCompositor(SingleBandCompositor):
"""Masks areas outside defined longitudes."""

def __init__(self, name, lon_min=None, lon_max=None, **kwargs): # noqa: D417

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just make the defaults -180.0 and 180.0? Then the if condition below can check for those values rather than None. You could also remove the float type definition in the docstring and specify it as a type annotation in the method definition (ex. name: str, lon_min: float = None, lat_min: float = None). Thoughts?

@codecov

codecov Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.47%. Comparing base (1356c9b) to head (fbe340f).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3536      +/-   ##
==========================================
+ Coverage   96.44%   96.47%   +0.02%     
==========================================
  Files         474      475       +1     
  Lines       61377    61436      +59     
==========================================
+ Hits        59194    59268      +74     
+ Misses       2183     2168      -15     
Flag Coverage Δ
behaviourtests 3.45% <0.00%> (-0.01%) ⬇️
unittests 96.55% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants