From bd6a5d1e5403aba71191c8c4013d216f4f3be799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Tue, 17 Dec 2024 17:19:45 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Deepak Cherian --- doc/whats-new.rst | 5 ++--- xarray/backends/api.py | 6 +++--- xarray/conventions.py | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 6d4dead1153..b64a801e0a3 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -27,7 +27,7 @@ New Features - Add ``unit`` - keyword argument to :py:func:`date_range` and ``microsecond`` parsing to iso8601-parser (:pull:`9885`). By `Kai Mühlbauer `_. -- Split out ``CFDatetimeCoder`` in ``xr.coders``, make ``decode_times`` keyword argument +- Split out ``CFDatetimeCoder`` as public API in ``xr.coders``, make ``decode_times`` keyword argument consume ``CFDatetimeCoder``. @@ -46,8 +46,7 @@ Deprecations :py:func:`date_range` (:pull:`9882`). By `Kai Mühlbauer `_. - Time decoding related kwarg ``use_cftime`` is deprecated. Use keyword argument - ``decode_times=CFDatetimeCoder(use_cftime=True)`` in the respective functions - instead. + ``decode_times=CFDatetimeCoder(use_cftime=True)`` in :py:func:`~xarray.open_dataset`, :py:func:`~xarray.open_dataarray`, :py:func:`~xarray.open_datatree`, :py:func:`~xarray.open_groups`, :py:func:`~xarray.open_zarr` and :py:func:`~xarray.decode_cf` instead. By `Kai Mühlbauer `_. Bug fixes diff --git a/xarray/backends/api.py b/xarray/backends/api.py index 12abb655e14..4b71c6d2f91 100644 --- a/xarray/backends/api.py +++ b/xarray/backends/api.py @@ -549,7 +549,7 @@ def open_dataset( This keyword may not be supported by all the backends. decode_times : bool, CFDatetimeCoder or dict-like, optional If True, decode times encoded in the standard NetCDF datetime format - into datetime objects. Otherwise, use CFDatetimeCoder or leave them encoded as numbers. + into datetime objects. Otherwise, use ``CFDatetimeCoder`` or leave them encoded as numbers. Pass a mapping, e.g. ``{"my_variable": False}``, to toggle this feature per-variable individually. This keyword may not be supported by all the backends. @@ -573,8 +573,8 @@ def open_dataset( raise an error. Pass a mapping, e.g. ``{"my_variable": False}``, to toggle this feature per-variable individually. This keyword may not be supported by all the backends. - Usage of 'use_cftime' as kwarg is deprecated. Please initialize it - with CFDatetimeCoder and 'decode_times' kwarg. + .. deprecated:: 2024.12.0 + Please initialize it with ``CFDatetimeCoder`` and ``decode_times`` kwarg. concat_characters : bool or dict-like, optional If True, concatenate along the last dimension of character arrays to form string arrays. Dimensions will only be concatenated over (and diff --git a/xarray/conventions.py b/xarray/conventions.py index 042a7f14032..1c2759cd631 100644 --- a/xarray/conventions.py +++ b/xarray/conventions.py @@ -199,7 +199,7 @@ def decode_cf_variable( if use_cftime is not None: from warnings import warn - warn( + emit_user_level_warning( "Usage of 'use_cftime' as kwarg is deprecated. " "Please initialize it with CFDatetimeCoder and " "'decode_times' kwarg.",