Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:languages:python:numeric
python-xarray
xarray-pr9403-np2.1-scalar.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xarray-pr9403-np2.1-scalar.patch of Package python-xarray
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):
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor