(self)
| 7557 | |
| 7558 | @requires_sparse |
| 7559 | def test_from_sparse(self) -> None: |
| 7560 | import sparse |
| 7561 | |
| 7562 | arr = np.diagflat([1, 2, 3]) |
| 7563 | sparr = sparse.COO.from_numpy(arr) |
| 7564 | da = xr.DataArray( |
| 7565 | sparr, dims=["x", "y"], coords={"elev": (("x", "y"), sparr + 3)} |
| 7566 | ) |
| 7567 | |
| 7568 | expected = xr.DataArray( |
| 7569 | arr, dims=["x", "y"], coords={"elev": (("x", "y"), arr + 3)} |
| 7570 | ) |
| 7571 | assert_identical(da.as_numpy(), expected) |
| 7572 | np.testing.assert_equal(da.to_numpy(), arr) |
| 7573 | |
| 7574 | @requires_cupy |
| 7575 | def test_from_cupy(self) -> None: |
nothing calls this directly
no test coverage detected