(self)
| 7541 | |
| 7542 | @requires_pint |
| 7543 | def test_from_pint(self) -> None: |
| 7544 | from pint import Quantity |
| 7545 | |
| 7546 | arr = np.array([1, 2, 3]) |
| 7547 | da = xr.DataArray( |
| 7548 | Quantity(arr, units="Pa"), |
| 7549 | dims="x", |
| 7550 | coords={"lat": ("x", Quantity(arr + 3, units="m"))}, |
| 7551 | ) |
| 7552 | |
| 7553 | expected = xr.DataArray(arr, dims="x", coords={"lat": ("x", arr + 3)}) |
| 7554 | assert_identical(da.as_numpy(), expected) |
| 7555 | np.testing.assert_equal(da.to_numpy(), arr) |
| 7556 | np.testing.assert_equal(da["lat"].to_numpy(), arr + 3) |
| 7557 | |
| 7558 | @requires_sparse |
| 7559 | def test_from_sparse(self) -> None: |
nothing calls this directly
no test coverage detected