1
0
forked from pool/python-xarray
python-xarray/xarray-pr9403-np2.1-scalar.patch
Sebastian Wagner d3af5d70ef - Update to 2024.7.0
* Add test for rechunking to a size string by @dcherian in #9117
  * Update docstring in api.py for open_mfdataset(), clarifying
    "chunks" argument by @arthur-e in #9121
  * Grouper refactor by @dcherian in #9122
  * adjust repr tests to account for different platforms (#9127) by
    @mgorny in #9128
  * Support duplicate dimensions in .chunk by @mraspaud in #9099
  * Update zendoo badge link by @max-sixty in #9133
  * Split out distributed writes in zarr docs by @max-sixty in
    #9132
  * Improve to_zarr docs by @max-sixty in #9139
  * groupby: remove some internal use of IndexVariable by @dcherian
    in #9123
  * Improve zarr chunks docs by @max-sixty in #9140
  * Include numbagg in type checks by @max-sixty in #9159
  * Remove mypy exclusions for a couple more libraries by
    @max-sixty in #9160
  * Add test for #9155 by @max-sixty in #9161
  * switch to datetime unit "D" by @keewis in #9170
  * Slightly improve DataTree repr by @shoyer in #9064
  * Fix example code formatting for CachingFileManager by @djhoese
    in #9178
  * Change np.core.defchararray to np.char (#9165) by @pont-us in
    #9166
  * temporarily remove pydap from CI by @keewis in #9183
  * also pin numpy in the all-but-dask CI by @keewis in #9184
  * promote floating-point numeric datetimes to 64-bit before
    decoding by @keewis in #9182
  * "source" encoding for datasets opened from fsspec objects by

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-xarray?expand=0&rev=99
2024-09-04 13:02:54 +00:00

45 lines
1.8 KiB
Diff

From 17367f3545a48d8b8a18bf8f7054b19351c255dc Mon Sep 17 00:00:00 2001
From: Justus Magin <keewis@posteo.de>
Date: Tue, 27 Aug 2024 15:18:32 +0200
Subject: [PATCH 1/3] also call `np.asarray` on numpy scalars
---
xarray/core/variable.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: xarray-2024.07.0/xarray/core/variable.py
===================================================================
--- xarray-2024.07.0.orig/xarray/core/variable.py
+++ xarray-2024.07.0/xarray/core/variable.py
@@ -309,7 +309,7 @@ def as_compatible_data(
else:
data = np.asarray(data)
- if not isinstance(data, np.ndarray) and (
+ if not isinstance(data, np.ndarray | np.generic) and (
hasattr(data, "__array_function__") or hasattr(data, "__array_namespace__")
):
return cast("T_DuckArray", data)
Index: xarray-2024.07.0/xarray/tests/test_variable.py
===================================================================
--- xarray-2024.07.0.orig/xarray/tests/test_variable.py
+++ xarray-2024.07.0/xarray/tests/test_variable.py
@@ -2585,10 +2585,15 @@ class TestAsCompatibleData(Generic[T_Duc
assert source_ndarray(x) is source_ndarray(as_compatible_data(x))
def test_converted_types(self):
- for input_array in [[[0, 1, 2]], pd.DataFrame([[0, 1, 2]])]:
+ for input_array in [
+ [[0, 1, 2]],
+ pd.DataFrame([[0, 1, 2]]),
+ np.float64(1.4),
+ np.str_("abc"),
+ ]:
actual = as_compatible_data(input_array)
assert_array_equal(np.asarray(input_array), actual)
- assert np.ndarray == type(actual)
+ assert np.ndarray is type(actual)
assert np.asarray(input_array).dtype == actual.dtype
def test_masked_array(self):