Skip to content

ensure compatibility with matplotblib 3.11.0#1228

Merged
TonioF merged 7 commits into
mainfrom
toniof/1219-matplotlib-3.11.0-compatibility
Jul 8, 2026
Merged

ensure compatibility with matplotblib 3.11.0#1228
TonioF merged 7 commits into
mainfrom
toniof/1219-matplotlib-3.11.0-compatibility

Conversation

@TonioF

@TonioF TonioF commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Solves #1219. The issue is that since matplotlib 3.11.0 color map values need to be given in a strictly ascending order; in our declaration of stepwise categorical color maps we state values as end points for one range and start points for the next one. I added a small value to the beginning of a range, so there is a tiny increase.

Checklist:

  • [ ] Add unit tests and/or doctests in docstrings
  • [ ] Add docstrings and API docs for any new/modified user-facing classes and functions
  • [ ] New/modified features documented in docs/source/*
  • Changes documented in CHANGES.md
  • GitHub CI passes
  • Test coverage remains or increases (target 100%)

@TonioF
TonioF requested review from clarasb and forman July 2, 2026 13:44
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.61%. Comparing base (76f9f4e) to head (36ea44f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1228      +/-   ##
==========================================
+ Coverage   89.59%   89.61%   +0.01%     
==========================================
  Files         280      280              
  Lines       21692    21694       +2     
==========================================
+ Hits        19436    19440       +4     
+ Misses       2256     2254       -2     

☔ 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.

@clarasb clarasb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, but please do not forget to update pyproject.toml as well ->

"matplotlib>=3.8.3,<3.11.0", #see Issue #1219

Comment thread CHANGES.md Outdated
### Fixes
* Improved raster tile alignment by using nearest-pixel rounding during tile reprojection,
reducing visual offsets between rendered map tiles and dataset coordinates. (#1216)
* ensure compatibility with matplotlib 3.11.0 (#1219)

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.

Suggested change
* ensure compatibility with matplotlib 3.11.0 (#1219)
* Ensure compatibility with matplotlib 3.11.0 (#1219)

Comment thread xcube/util/cmaps.py
Comment on lines +528 to +530
stepwise_cm_items.append((value + offset, color))
stepwise_cm_items.append((next_value, color))
offset = 1e-8

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.

Please explain

  • the magic constant used here,
  • why this does "ensure compatibility with matplotlib 3.11.0".

Comment in code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The offset here stands for a very small value, just large enough to serve to create a difference in floating point numbers. The reason to set it is that when we create a series of stepwise_cm_items, matplotlib since v3.11.0 requires these to be strictly mononically increasing, otherwise an error is thrown and we continue with the fallback code.
I guess it makes sense to call the constant EPSILON to make it clearer.

Another option would have been to try to reimplement the former matplotlib code in xcube, but I preferred this solution.

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.

Just leave a comment in the code so someone else understands the magic.

Comment thread environment.yml Outdated
- libgdal-jp2openjpeg
- mashumaro
- matplotlib-base >=3.8.3,<3.11.0 # see Issue #1219
- matplotlib-base >=3.8.3

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.

Suggested change
- matplotlib-base >=3.8.3
- matplotlib-base >=3.8.3,<4

@TonioF
TonioF requested a review from forman July 7, 2026 11:39
@TonioF
TonioF merged commit 8b3dc66 into main Jul 8, 2026
6 checks passed
@TonioF
TonioF deleted the toniof/1219-matplotlib-3.11.0-compatibility branch July 8, 2026 13:10
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.

3 participants