Skip to content

Conversation

Illviljan
Copy link
Contributor

@Illviljan Illviljan commented Oct 9, 2025

Colormaps are slowly becoming immutable, matplotlib/matplotlib#30531.

Fixes the upstream issues:

xarray/tests/test_plot.py::TestPlot::test_contourf_cmap_set_with_bad_under_over: PendingDeprecationWarning: The set_bad function will be deprecated in a future version. Use cmap.with_extremes(bad=...) or Colormap(bad=...) instead.
xarray/tests/test_plot.py::TestDiscreteColorMap::test_discrete_colormap_int_levels: PendingDeprecationWarning: The set_bad function will be deprecated in a future version. Use cmap.with_extremes(bad=...) or Colormap(bad=...) instead.

@Illviljan Illviljan added run-upstream Run upstream CI and removed topic-plotting labels Oct 9, 2025
@Illviljan Illviljan changed the title Switch to set_extremes, set_bad is deprecated Switch to with_extremes, set_extremes is deprecated Oct 9, 2025
@ianhi
Copy link
Contributor

ianhi commented Oct 9, 2025

set_extremes was introduced in 3.4 https://matplotlib.org/stable/users/prev_whats_new/whats_new_3.4.0.html#colormap-set-extremes-and-colormap-with-extremes

So I think this PR needs to update the xarray matplotlib viz extra to include matplotlib>=3.4. It is currently unbounded

@Illviljan
Copy link
Contributor Author

So I think this PR needs to update the xarray matplotlib viz extra to include matplotlib>=3.4. It is currently unbounded

Odd, our minimum version policy says 3.8:

 ╭─────────────────────────────────────────────── min-all-deps ───────────────────────────────────────────────╮
│                  ┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━┓ │
│                  ┃ Package              ┃ Required ┃ Required (date) ┃ Policy   ┃ Policy (date) ┃ Status ┃ │
│                  ┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━┩ │
│                  │ python               │ 3.11     │ 2022-10-25      │ 3.11     │ 2022-10-25    │ =      │ │
│                  │ array-api-strict     │ 1.1      │ 2024-03-09      │ 2.0      │ 2024-06-28    │ <      │ │
│                  │ boto3                │ 1.34     │ 2023-12-14      │ 1.35     │ 2024-08-17    │ <      │ │
│                  │ bottleneck           │ 1.4      │ 2024-06-18      │ 1.4      │ 2024-06-18    │ =      │ │
│                  │ cartopy              │ 0.23     │ 2024-04-11      │ 0.24     │ 2024-10-07    │ <      │ │
│                  │ cftime               │ 1.6      │ 2022-03-03      │ 1.6      │ 2022-03-03    │ =      │ │
│                  │ dask-core            │ 2024.6   │ 2024-06-14      │ 2024.9   │ 2024-09-13    │ <      │ │
│                  │ distributed          │ 2024.6   │ 2024-06-14      │ 2024.9   │ 2024-09-13    │ <      │ │
│                  │ flox                 │ 0.9      │ 2024-01-23      │ 0.9      │ 2024-01-23    │ =      │ │
│                  │ h5netcdf             │ 1.3      │ 2023-11-08      │ 1.4      │ 2024-10-07    │ <      │ │
│                  │ h5py                 │ 3.11     │ 2024-04-10      │ 3.11     │ 2024-04-10    │ =      │ │
│                  │ hdf5                 │ 1.14     │ 2023-02-05      │ 1.14     │ 2023-02-05    │ =      │ │
│                  │ iris                 │ 3.9      │ 2024-04-22      │ 3.10     │ 2024-08-13    │ <      │ │
│ Version summary  │ lxml                 │ 5.1      │ 2024-01-08      │ 5.3      │ 2024-08-12    │ <      │ │
│                  │ matplotlib-base      │ 3.8      │ 2023-09-18      │ 3.8      │ 2023-09-18    │ =      │ │
│                  │ nc-time-axis         │ 1.4      │ 2021-10-23      │ 1.4      │ 2021-10-23    │ =      │ │
│                  │ netcdf4              │ 1.6      │ 2022-06-29      │ 1.6      │ 2022-06-29    │ =      │ │
│                  │ numba                │ 0.60     │ 2024-06-20      │ 0.60     │ 2024-06-20    │ =      │ │
│                  │ numbagg              │ 0.8      │ 2024-02-03      │ 0.8      │ 2024-02-03    │ =      │ │
│                  │ numpy                │ 1.26     │ 2023-09-17      │ 1.26     │ 2023-09-17    │ =      │ │
│                  │ packaging            │ 24.1     │ 2024-06-12      │ 24.1     │ 2024-06-12    │ =      │ │
│                  │ pandas               │ 2.2      │ 2024-01-20      │ 2.2      │ 2024-01-20    │ =      │ │
│                  │ pint                 │ 0.24     │ 2024-06-11      │ 0.24     │ 2024-06-11    │ =      │ │
│                  │ pydap                │ 3.5.0    │ 2024-08-21      │ 3.5      │ 2024-08-21    │ =      │ │
│                  │ rasterio             │ 1.3      │ 2022-07-06      │ 1.4      │ 2024-09-27    │ <      │ │
│                  │ scipy                │ 1.13     │ 2024-04-04      │ 1.14     │ 2024-06-25    │ <      │ │
│                  │ seaborn              │ 0.13     │ 2023-10-02      │ 0.13     │ 2023-10-02    │ =      │ │
│                  │ sparse               │ 0.15     │ 2024-01-09      │ 0.15     │ 2024-01-09    │ =      │ │
│                  │ toolz                │ 0.12     │ 2022-07-10      │ 1.0      │ 2024-10-04    │ <      │ │
│                  │ zarr                 │ 2.18     │ 2024-05-08      │ 2.18     │ 2024-05-08    │ =      │ │
│                  └──────────────────────┴──────────┴─────────────────┴──────────┴───────────────┴────────┘ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

@ianhi
Copy link
Contributor

ianhi commented Oct 9, 2025

Odd, our minimum version policy says 3.8:

Ahh that's a much more reasonable bound. Although it's not currently encoded in the actual requirements

viz = ["cartopy>=0.23", "matplotlib", "nc-time-axis", "seaborn"]

@Illviljan
Copy link
Contributor Author

yeah, I'm not sure why that is. It might be intended:

xarray/pyproject.toml

Lines 23 to 26 in 20d3773

# We don't encode minimum requirements here (though if we can write a script to
# generate the text from `min_deps_check.py`, that's welcome...). We do add
# `numba>=0.54` here because of https://github.com/astral-sh/uv/issues/7881;
# note that it's not a direct dependency of xarray.

@Illviljan Illviljan marked this pull request as ready for review October 9, 2025 20:35
@Illviljan
Copy link
Contributor Author

Illviljan commented Oct 9, 2025

Only the unrelated pandas error left now:

 =========================== short test summary info ============================
FAILED properties/test_pandas_roundtrip.py::test_roundtrip_1d_pandas_extension_array[False-string] - assert <StringDtype(na_value=<NA>)> == <StringDtype(na_value=nan)>
 +  where <StringDtype(na_value=<NA>)> = 0    a\n1    b\n2    c\nName: arr, dtype: string.dtype
 +  and   <StringDtype(na_value=nan)> = index\n0    a\n1    b\n2    c\nName: arr, dtype: str.dtype

@Illviljan Illviljan changed the title Switch to with_extremes, set_extremes is deprecated Switch to cmap.with_extremes, cmap.set_extremes is deprecated Oct 9, 2025
@Illviljan Illviljan changed the title Switch to cmap.with_extremes, cmap.set_extremes is deprecated Switch to use cmap.with_extremes Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚠️ Nightly upstream-dev CI failed ⚠️

2 participants