You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some of our tests that passed before the new year are failing now. The error is raised by some new xarray code, which might have first been on the Jan 2025 release of xarray.
This is the error:
def transpose(array, axes=None):
xp = get_array_namespace(array)
> return xp.transpose(array, axes)
E AttributeError: module 'sparse' has no attribute 'transpose'
I included the full traceback below. Since this is on our CI, I can't run xr.show_versions() directly, but I included the versions of xarray and sparse. I will try to reproduce it locally.
I don't have a MCVE. For context, the function that raises this error defines a ufunc that calls sparse.tensordot. I haven't had time to raise an issue for this, but about a year ago, I was having trouble using @ to multiply a sparse data array and a non-sparse data array, so I wrote a ufunc to do it. I think matrix mult. with one or more sparse data arrays works in some cases, and maybe this has been fixed in the interim.
I reproduced the error locally, and updated the environment details below
What did you expect to happen?
Nothing has changed in the part of our code that is raising this error, so I would expect these tests to keep passing. The tests pass with sparse 15.4.0 and xarray 2024.11.0.
Minimal Complete Verifiable Example
No response
MVCE confirmation
Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
Complete example — the example is self-contained, including all data and the text of any traceback.
Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
New issue — a search of GitHub Issues suggests this is not a duplicate.
Recent environment — the issue occurs with the latest version of xarray and its dependencies.
looks like the Array API defines the all-axis transpose as permute_dims with a tuple parameter (no default), so we might have to use that instead (and compute a default value)
Looks like this is used a grand total of one time in the codebase, so yeah we should probably switch to the proper Array API method permute_dims including renaming our duck_array_op. Would also be good to find a way to hit this code path in these tests, which ideally would have caught this.
What happened?
Some of our tests that passed before the new year are failing now. The error is raised by some new xarray code, which might have first been on the Jan 2025 release of xarray.
This is the error:
I included the full traceback below. Since this is on our CI, I can't run
xr.show_versions()
directly, but I included the versions of xarray and sparse. I will try to reproduce it locally.I don't have a MCVE. For context, the function that raises this error defines a ufunc that calls
sparse.tensordot
. I haven't had time to raise an issue for this, but about a year ago, I was having trouble using@
to multiply a sparse data array and a non-sparse data array, so I wrote a ufunc to do it. I think matrix mult. with one or more sparse data arrays works in some cases, and maybe this has been fixed in the interim.This is the function that raises the error: https://github.com/openghg/openghg_inversions/blob/devel/openghg_inversions/array_ops.py#L75
Updates:
dask @ sparse
works,sparse @ dask
fails #9934What did you expect to happen?
Nothing has changed in the part of our code that is raising this error, so I would expect these tests to keep passing. The tests pass with sparse 15.4.0 and xarray 2024.11.0.
Minimal Complete Verifiable Example
No response
MVCE confirmation
Relevant log output
Anything else we need to know?
As far as I can tell,
sparse
does not exporttranspose
, so presumably any code that triggers the duck array transpose for a sparse array should raise this error. https://github.com/pydata/sparse/blob/0.15.4/sparse/__init__.pyEnvironment
xarray: 2025.1.0
pandas: 2.2.3
numpy: 1.26.4
scipy: 1.15.0
netCDF4: 1.6.5
pydap: None
h5netcdf: 1.4.1
h5py: 3.12.1
zarr: 2.18.3
cftime: 1.6.4.post1
nc_time_axis: 1.4.1
iris: None
bottleneck: None
dask: 2024.12.1
distributed: None
matplotlib: 3.10.0
cartopy: None
seaborn: None
numbagg: None
fsspec: 2024.12.0
cupy: None
pint: None
sparse: 0.15.4
flox: None
numpy_groupies: None
setuptools: 75.8.0
pip: 24.3.1
conda: None
pytest: 8.3.4
mypy: None
IPython: 8.31.0
sphinx: None
The text was updated successfully, but these errors were encountered: