MCPcopy Index your code
hub / github.com/pydata/xarray / test_from_pint

Method test_from_pint

xarray/tests/test_dataarray.py:7543–7556  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 4

as_numpyMethod · 0.95
to_numpyMethod · 0.95
assert_identicalFunction · 0.90
to_numpyMethod · 0.45

Tested by

no test coverage detected