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

Function test_decode_signed_from_unsigned

xarray/tests/test_coding.py:139–149  ·  view source on GitHub ↗
(bits)

Source from the content-addressed store, hash-verified

137
138@pytest.mark.parametrize("bits", [1, 2, 4, 8])
139def test_decode_signed_from_unsigned(bits) -> None:
140 unsigned_dtype = np.dtype(f"u{bits}")
141 signed_dtype = np.dtype(f"i{bits}")
142 original_values = np.array([-1], dtype=signed_dtype)
143 encoded = xr.Variable(
144 ("x",), original_values.astype(unsigned_dtype), attrs={"_Unsigned": "false"}
145 )
146 coder = variables.CFMaskCoder()
147 decoded = coder.decode(encoded)
148 assert decoded.dtype == signed_dtype
149 assert decoded.values == original_values

Callers

nothing calls this directly

Calls 3

decodeMethod · 0.95
dtypeMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…