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

Method test_from_pint

xarray/tests/test_dataset.py:8332–8342  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

8330
8331 @requires_pint
8332 def test_from_pint(self) -> None:
8333 from pint import Quantity
8334
8335 arr = np.array([1, 2, 3])
8336 ds = xr.Dataset(
8337 {"a": ("x", Quantity(arr, units="Pa"))},
8338 coords={"lat": ("x", Quantity(arr + 3, units="m"))},
8339 )
8340
8341 expected = xr.Dataset({"a": ("x", [1, 2, 3])}, coords={"lat": ("x", arr + 3)})
8342 assert_identical(ds.as_numpy(), expected)
8343
8344 @requires_sparse
8345 def test_from_sparse(self) -> None:

Callers

nothing calls this directly

Calls 2

as_numpyMethod · 0.95
assert_identicalFunction · 0.90

Tested by

no test coverage detected