diff --git a/doc/api.rst b/doc/api.rst index 85ef46ca6ba..103f3984512 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -36,6 +36,7 @@ Top-level functions dot polyval map_blocks + show_backends show_versions set_options get_options diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 08e6218ca14..dc94c7c10f6 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -21,6 +21,8 @@ v.2024.12.0 (unreleased) New Features ~~~~~~~~~~~~ +- Add :py:func:`~xarray.show_backends` alias for :py:func:`~xarray.backends.list_engines` (:issue:`6577`, :pull:`9821`). + By `Nick Hodgskin `_. - Better support wrapping additional array types (e.g. ``cupy`` or ``jax``) by calling generalized duck array operations throughout more xarray methods. (:issue:`7848`, :pull:`9798`). By `Sam Levang `_. diff --git a/xarray/__init__.py b/xarray/__init__.py index 622c927b468..7a31d5eb4a9 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -11,6 +11,7 @@ open_mfdataset, save_mfdataset, ) +from xarray.backends.plugins import show_backends from xarray.backends.zarr import open_zarr from xarray.coding.cftime_offsets import cftime_range, date_range, date_range_like from xarray.coding.cftimeindex import CFTimeIndex @@ -108,6 +109,7 @@ "register_datatree_accessor", "save_mfdataset", "set_options", + "show_backends", "show_versions", "unify_chunks", "where", diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index 555538c2562..c4e09b5939f 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -132,6 +132,19 @@ def list_engines() -> dict[str, BackendEntrypoint]: return build_engines(entrypoints) +def show_backends() -> dict[str, BackendEntrypoint]: + """ + Return a dictionary of available engines and their BackendEntrypoint objects. + + This function is an alias for ``xarray.backends.list_engines``. + + Returns + ------- + dictionary + """ + return list_engines() + + def refresh_engines() -> None: """Refreshes the backend engines based on installed packages.""" list_engines.cache_clear() diff --git a/xarray/tests/test_plugins.py b/xarray/tests/test_plugins.py index 2b321ba8dfc..4f9b07725e6 100644 --- a/xarray/tests/test_plugins.py +++ b/xarray/tests/test_plugins.py @@ -276,6 +276,13 @@ def test_list_engines() -> None: assert "store" in engines +def test_show_engines() -> None: + from xarray import show_backends + from xarray.backends import list_engines + + assert show_backends() == list_engines() + + def test_refresh_engines() -> None: from xarray.backends import list_engines, refresh_engines