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

Method test_from_pint

xarray/tests/test_variable.py:3101–3112  ·  view source on GitHub ↗
(self, Var)

Source from the content-addressed store, hash-verified

3099
3100 @requires_pint
3101 def test_from_pint(self, Var):
3102 import pint
3103
3104 arr = np.array([1, 2, 3])
3105
3106 # IndexVariable strips the unit
3107 with warnings.catch_warnings():
3108 warnings.simplefilter("ignore", category=pint.UnitStrippedWarning)
3109 v = Var("x", pint.Quantity(arr, units="m"))
3110
3111 assert_identical(v.as_numpy(), Var("x", arr))
3112 np.testing.assert_equal(v.to_numpy(), arr)
3113
3114 @requires_sparse
3115 def test_from_sparse(self, Var):

Callers

nothing calls this directly

Calls 3

assert_identicalFunction · 0.90
as_numpyMethod · 0.45
to_numpyMethod · 0.45

Tested by

no test coverage detected