Skip to content

Commit

Permalink
Merge branch 'main' into py313
Browse files Browse the repository at this point in the history
  • Loading branch information
keewis committed Oct 25, 2024
2 parents ddda851 + 5be821b commit 592695c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 18 deletions.
62 changes: 47 additions & 15 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,45 @@ What's New
np.random.seed(123456)
.. _whats-new.2024.09.1:
.. _whats-new.2024.10.1:

v2024.09.1 (unreleased)
-----------------------
v.2024.10.1 (unreleased)
------------------------

New Features
~~~~~~~~~~~~


Breaking changes
~~~~~~~~~~~~~~~~


Deprecations
~~~~~~~~~~~~


Bug fixes
~~~~~~~~~


Documentation
~~~~~~~~~~~~~


Internal Changes
~~~~~~~~~~~~~~~~

.. _whats-new.2024.10.0:

v2024.10.0 (Oct 24th, 2024)
---------------------------

This release brings official support for `xarray.DataTree`, and compatibility with zarr-python v3!

Aside from these two huge features, it also improves support for vectorised interpolation and fixes various bugs.

Thanks to the 31 contributors to this release:
Alfonso Ladino, DWesl, Deepak Cherian, Eni, Etienne Schalk, Holly Mandel, Ilan Gold, Illviljan, Joe Hamman, Justus Magin, Kai Mühlbauer, Karl Krauth, Mark Harfouche, Martey Dodoo, Matt Savoie, Maximilian Roos, Patrick Hoefler, Peter Hill, Renat Sibgatulin, Ryan Abernathey, Spencer Clark, Stephan Hoyer, Tom Augspurger, Tom Nicholas, Vecko, Virgile Andreani, Yvonne Fröhlich, carschandler, joseph nowak, mgunyho and owenlittlejohns

New Features
~~~~~~~~~~~~
Expand All @@ -34,17 +69,20 @@ New Features
`Alfonso Ladino <https://github.com/aladinor>`_.
- A migration guide for users of the prototype `xarray-contrib/datatree repository <https://github.com/xarray-contrib/datatree>`_ has been added, and can be found in the `DATATREE_MIGRATION_GUIDE.md` file in the repository root.
By `Tom Nicholas <https://github.com/TomNicholas>`_.
- Support for Zarr-Python 3 (:issue:`95515`, :pull:`9552`).
By `Tom Augspurger <https://github.com/TomAugspurger>`_,
`Ryan Abernathey <https://github.com/rabernat>`_ and
`Joe Hamman <https://github.com/jhamman>`_.
- Added zarr backends for :py:func:`open_groups` (:issue:`9430`, :pull:`9469`).
By `Eni Awowale <https://github.com/eni-awowale>`_.
- Added support for vectorized interpolation using additional interpolators
from the ``scipy.interpolate`` module (:issue:`9049`, :pull:`9526`).
By `Holly Mandel <https://github.com/hollymandel>`_.
- Implement handling of complex numbers (netcdf4/h5netcdf) and enums (h5netcdf) (:issue:`9246`, :issue:`3297`, :pull:`9509`).
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
- Support for Zarr-Python 3 (:issue:`95515`, :pull:`9552`).
By `Tom Augspurger <https://github.com/TomAugspurger>`_,
`Ryan Abernathey <https://github.com/rabernat>`_ and
`Joe Hamman <https://github.com/jhamman>`_.
- Fix passing missing arguments to when opening hdf5 and netCDF4 datatrees
(:issue:`9427`, :pull: `9428`).
By `Alfonso Ladino <https://github.com/aladinor>`_.

Breaking changes
~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -76,6 +114,8 @@ Bug fixes
<https://github.com/josephnowak>`_.
- Fix binning by multiple variables where some bins have no observations. (:issue:`9630`).
By `Deepak Cherian <https://github.com/dcherian>`_.
- Fix issue where polyfit wouldn't handle non-dimension coordinates. (:issue:`4375`, :pull:`9369`)
By `Karl Krauth <https://github.com/Karl-Krauth>`_.

Documentation
~~~~~~~~~~~~~
Expand All @@ -86,12 +126,9 @@ Documentation
By `Owen Littlejohns <https://github.com/owenlittlejohns>`_, `Matt Savoie <https://github.com/flamingbear>`_, and
`Tom Nicholas <https://github.com/TomNicholas>`_.



Internal Changes
~~~~~~~~~~~~~~~~


.. _whats-new.2024.09.0:

v2024.09.0 (Sept 11, 2024)
Expand Down Expand Up @@ -159,17 +196,12 @@ Bug fixes
date "0001-01-01". (:issue:`9108`, :pull:`9116`) By `Spencer Clark
<https://github.com/spencerkclark>`_ and `Deepak Cherian
<https://github.com/dcherian>`_.
- Fix issue where polyfit wouldn't handle non-dimension coordinates. (:issue:`4375`, :pull:`9369`)
By `Karl Krauth <https://github.com/Karl-Krauth>`_.
- Fix issue with passing parameters to ZarrStore.open_store when opening
datatree in zarr format (:issue:`9376`, :pull:`9377`).
By `Alfonso Ladino <https://github.com/aladinor>`_
- Fix deprecation warning that was raised when calling ``np.array`` on an ``xr.DataArray``
in NumPy 2.0 (:issue:`9312`, :pull:`9393`)
By `Andrew Scherer <https://github.com/andrew-s28>`_.
- Fix passing missing arguments to when opening hdf5 and netCDF4 datatrees
(:issue:`9427`, :pull: `9428`).
By `Alfonso Ladino <https://github.com/aladinor>`_.
- Fix support for using ``pandas.DateOffset``, ``pandas.Timedelta``, and
``datetime.timedelta`` objects as ``resample`` frequencies
(:issue:`9408`, :pull:`9413`).
Expand Down
14 changes: 11 additions & 3 deletions xarray/core/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,17 @@ def isdtype(dtype, kind: str | tuple[str, ...], xp=None) -> bool:
return xp.isdtype(dtype, kind)


def preprocess_scalar_types(t):
def preprocess_types(t):
if isinstance(t, str | bytes):
return type(t)
elif isinstance(dtype := getattr(t, "dtype", t), np.dtype) and (
np.issubdtype(dtype, np.str_) or np.issubdtype(dtype, np.bytes_)
):
# drop the length from numpy's fixed-width string dtypes, it is better to
# recalculate
# TODO(keewis): remove once the minimum version of `numpy.result_type` does this
# for us
return dtype.type
else:
return t

Expand Down Expand Up @@ -255,7 +263,7 @@ def result_type(
xp = get_array_namespace(arrays_and_dtypes)

types = {
array_api_compat.result_type(preprocess_scalar_types(t), xp=xp)
array_api_compat.result_type(preprocess_types(t), xp=xp)
for t in arrays_and_dtypes
}
if any(isinstance(t, np.dtype) for t in types):
Expand All @@ -268,5 +276,5 @@ def result_type(
return np.dtype(object)

return array_api_compat.result_type(
*map(preprocess_scalar_types, arrays_and_dtypes), xp=xp
*map(preprocess_types, arrays_and_dtypes), xp=xp
)
4 changes: 4 additions & 0 deletions xarray/tests/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class DummyArrayAPINamespace:
([np.str_, np.int64], np.object_),
([np.str_, np.str_], np.str_),
([np.bytes_, np.str_], np.object_),
([np.dtype("<U2"), np.str_], np.dtype("U")),
([np.dtype("<U2"), str], np.dtype("U")),
([np.dtype("S3"), np.bytes_], np.dtype("S")),
([np.dtype("S10"), bytes], np.dtype("S")),
],
)
def test_result_type(args, expected) -> None:
Expand Down

0 comments on commit 592695c

Please sign in to comment.