Skip to content

Commit 35fa479

Browse files
authored
Prepare 0.22 release (#2460)
* update requirements and add fix for next matplotlib release * modify mpl style use condition * fix if backend conditions in plot_kde * take pre-releases into account * informative errors on unsupported zarr versions * update warning on non-interactive matplotlib backends * rerun migration guide and update version number * fix version reference
1 parent e17dedf commit 35fa479

File tree

7 files changed

+4344
-382
lines changed

7 files changed

+4344
-382
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Change Log
22

3-
## Unreleased
3+
## v0.22.0 (2025 Jul 9)
44

55
### New features
66
- `plot_pair` now has more flexible support for `reference_values` ([2438](https://github.com/arviz-devs/arviz/pull/2438))
77
- Make `arviz.from_numpyro(..., dims=None)` automatically infer dims from the numpyro model based on its numpyro.plate structure
88

9-
109
### Maintenance and fixes
1110
- `reference_values` and `labeller` now work together in `plot_pair` ([2437](https://github.com/arviz-devs/arviz/issues/2437))
1211
- Fix `plot_lm` for multidimensional data ([2408](https://github.com/arviz-devs/arviz/issues/2408))
1312
- Add [`scipy-stubs`](https://github.com/scipy/scipy-stubs) as a development dependency ([2445](https://github.com/arviz-devs/arviz/pull/2445))
1413
- Test compare dataframe stays consistent independently of input order ([2407](https://github.com/arviz-devs/arviz/pull/2407))
14+
- Fix hdi_probs behaviour in 2d `plot_kde` ([2460](https://github.com/arviz-devs/arviz/pull/2460))
1515

1616
### Documentation
1717
- Added documentation for `reference_values` ([2438](https://github.com/arviz-devs/arviz/pull/2438))
18+
- Add migration guide page to help switch over to the new `arviz-xyz` libraries ([2459](https://github.com/arviz-devs/arviz/pull/2459))
1819

1920
## v0.21.0 (2025 Mar 06)
2021

arviz/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# pylint: disable=wildcard-import,invalid-name,wrong-import-position
22
"""ArviZ is a library for exploratory analysis of Bayesian models."""
3-
__version__ = "0.22.0dev"
3+
__version__ = "0.22.0"
44

55
import logging
66
import os
77

88
from matplotlib.colors import LinearSegmentedColormap
99
from matplotlib.pyplot import style
1010
import matplotlib as mpl
11+
from packaging import version
1112

1213

1314
class Logger(logging.Logger):
@@ -41,8 +42,12 @@ def _log(
4142

4243
# add ArviZ's styles to matplotlib's styles
4344
_arviz_style_path = os.path.join(os.path.dirname(__file__), "plots", "styles")
44-
style.core.USER_LIBRARY_PATHS.append(_arviz_style_path)
45-
style.core.reload_library()
45+
if version.parse(mpl.__version__) >= version.parse("3.11.0.dev0"):
46+
style.USER_LIBRARY_PATHS.append(_arviz_style_path)
47+
style.reload_library()
48+
else:
49+
style.core.USER_LIBRARY_PATHS.append(_arviz_style_path)
50+
style.core.reload_library()
4651

4752

4853
if not logging.root.handlers:

arviz/data/inference_data.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -800,12 +800,20 @@ def to_zarr(self, store=None):
800800
----------
801801
https://zarr.readthedocs.io/
802802
"""
803-
try: # Check zarr
803+
try:
804804
import zarr
805-
806-
assert version.parse(zarr.__version__) >= version.parse("2.5.0")
807-
except (ImportError, AssertionError) as err:
808-
raise ImportError("'to_zarr' method needs Zarr (2.5.0+) installed.") from err
805+
except ImportError as err:
806+
raise ImportError("'to_zarr' method needs Zarr (>=2.5.0,<3) installed.") from err
807+
if version.parse(zarr.__version__) < version.parse("2.5.0"):
808+
raise ImportError(
809+
"Found zarr<2.5.0, please upgrade to a zarr (>=2.5.0,<3) to use 'to_zarr'"
810+
)
811+
if version.parse(zarr.__version__) >= version.parse("3.0.0.dev0"):
812+
raise ImportError(
813+
"Found zarr>=3, which is not supported by ArviZ. Instead, you can use "
814+
"'dt = InfereceData.to_datatree' followed by 'dt.to_zarr()' "
815+
"(needs xarray>=2024.11.0)"
816+
)
809817

810818
# Check store type and create store if necessary
811819
if store is None:
@@ -854,10 +862,18 @@ def from_zarr(store) -> "InferenceData":
854862
"""
855863
try:
856864
import zarr
857-
858-
assert version.parse(zarr.__version__) >= version.parse("2.5.0")
859-
except (ImportError, AssertionError) as err:
860-
raise ImportError("'to_zarr' method needs Zarr (2.5.0+) installed.") from err
865+
except ImportError as err:
866+
raise ImportError("'from_zarr' method needs Zarr (>=2.5.0,<3) installed.") from err
867+
if version.parse(zarr.__version__) < version.parse("2.5.0"):
868+
raise ImportError(
869+
"Found zarr<2.5.0, please upgrade to a zarr (>=2.5.0,<3) to use 'from_zarr'"
870+
)
871+
if version.parse(zarr.__version__) >= version.parse("3.0.0.dev0"):
872+
raise ImportError(
873+
"Found zarr>=3, which is not supported by ArviZ. Instead, you can use "
874+
"'xarray.open_datatree' followed by 'arviz.InferenceData.from_datatree' "
875+
"(needs xarray>=2024.11.0)"
876+
)
861877

862878
# Check store type and create store if necessary
863879
if isinstance(store, str):

arviz/plots/backends/matplotlib/khatplot.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import matplotlib.pyplot as plt
88
import numpy as np
99
from matplotlib.colors import to_rgba_array
10+
from packaging import version
1011

1112
from ....stats.density_utils import histogram
1213
from ...plot_utils import _scale_fig_size, color_from_dim, set_xticklabels, vectorized_to_hex
@@ -39,7 +40,13 @@ def plot_khat(
3940
show,
4041
):
4142
"""Matplotlib khat plot."""
42-
if hover_label and mpl.get_backend() not in mpl.rcsetup.interactive_bk:
43+
if version.parse(mpl.__version__) >= version.parse("3.9.0.dev0"):
44+
interactive_backends = mpl.backends.backend_registry.list_builtin(
45+
mpl.backends.BackendFilter.INTERACTIVE
46+
)
47+
else:
48+
interactive_backends = mpl.rcsetup.interactive_bk
49+
if hover_label and mpl.get_backend() not in interactive_backends:
4350
hover_label = False
4451
warnings.warn(
4552
"hover labels are only available with interactive backends. To switch to an "

arviz/plots/kdeplot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ def plot_kde(
255255
"or plot_pair instead of plot_kde"
256256
)
257257

258+
if backend is None:
259+
backend = rcParams["plot.backend"]
260+
backend = backend.lower()
261+
258262
if values2 is None:
259263
if bw == "default":
260264
bw = "taylor" if is_circular else "experimental"
@@ -346,10 +350,6 @@ def plot_kde(
346350
**kwargs,
347351
)
348352

349-
if backend is None:
350-
backend = rcParams["plot.backend"]
351-
backend = backend.lower()
352-
353353
# TODO: Add backend kwargs
354354
plot = get_plotting_function("plot_kde", "kdeplot", backend)
355355
ax = plot(**kde_plot_args)

0 commit comments

Comments
 (0)