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

Function test_EncodedStringCoder_encode

xarray/tests/test_coding_strings.py:88–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86
87
88def test_EncodedStringCoder_encode() -> None:
89 dtype = strings.create_vlen_dtype(str)
90 raw_data = np.array(["abc", "ß∂µ∆"], dtype=dtype)
91 expected_data = np.array([r.encode("utf-8") for r in raw_data], dtype=object)
92
93 coder = strings.EncodedStringCoder(allows_unicode=True)
94 raw = Variable(("x",), raw_data, encoding={"dtype": "S1"})
95 actual = coder.encode(raw)
96 expected = Variable(("x",), expected_data, attrs={"_Encoding": "utf-8"})
97 assert_identical(actual, expected)
98
99 raw = Variable(("x",), raw_data)
100 assert_identical(coder.encode(raw), raw)
101
102 coder = strings.EncodedStringCoder(allows_unicode=False)
103 assert_identical(coder.encode(raw), expected)
104
105
106@pytest.mark.skipif(

Callers

nothing calls this directly

Calls 4

encodeMethod · 0.95
VariableClass · 0.90
assert_identicalFunction · 0.90
encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…