()
| 86 | |
| 87 | |
| 88 | def 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( |
nothing calls this directly
no test coverage detected
searching dependent graphs…