MCPcopy
hub / github.com/pydata/xarray / test_scaling_converts_to_float

Function test_scaling_converts_to_float

xarray/tests/test_coding.py:99–109  ·  view source on GitHub ↗
(dtype: str, dtype2: str)

Source from the content-addressed store, hash-verified

97@pytest.mark.parametrize("dtype", ["u1", "u2", "i1", "i2", "f2", "f4"])
98@pytest.mark.parametrize("dtype2", ["f4", "f8"])
99def test_scaling_converts_to_float(dtype: str, dtype2: str) -> None:
100 dt = np.dtype(dtype2)
101 original = xr.Variable(
102 ("x",), np.arange(10, dtype=dtype), encoding=dict(scale_factor=dt.type(10))
103 )
104 coder = variables.CFScaleOffsetCoder()
105 encoded = coder.encode(original)
106 assert encoded.dtype == dt
107 roundtripped = coder.decode(encoded)
108 assert_identical(original, roundtripped)
109 assert roundtripped.dtype == dt
110
111
112@pytest.mark.parametrize("scale_factor", (10, [10]))

Callers

nothing calls this directly

Calls 5

encodeMethod · 0.95
decodeMethod · 0.95
assert_identicalFunction · 0.90
arangeMethod · 0.80
dtypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…