Skip to content

Commit

Permalink
Fix syntax error in test related to cupy (#9000)
Browse files Browse the repository at this point in the history
I suspect the CIs don't have cupy which meant that this line didn't get
hit.

Recreation:

```
mamba create --name xr_py10 python=3.10 --channel conda-forge --override-channels
mamba activate xr_py10
pip install -e . -vv
pip install pytest
mamba install cupy
```

```
pytest xarray/tests/test_array_api.py -x
```

Fails on my machine.

Happy to provide more info
  • Loading branch information
hmaarrfk authored May 5, 2024
1 parent aaa778c commit c2b9429
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions xarray/core/duck_array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ def as_shared_dtype(scalars_or_arrays, xp=np):
raise ValueError(
f"Cannot cast arrays to shared type, found array types {[x.dtype for x in scalars_or_arrays]}"
)
elif array_type_cupy := array_type("cupy") and any( # noqa: F841
isinstance(x, array_type_cupy) for x in scalars_or_arrays # noqa: F821
):

# Avoid calling array_type("cupy") repeatidely in the any check
array_type_cupy = array_type("cupy")
if any(isinstance(x, array_type_cupy) for x in scalars_or_arrays):
import cupy as cp

arrays = [asarray(x, xp=cp) for x in scalars_or_arrays]
Expand Down

0 comments on commit c2b9429

Please sign in to comment.