MCPcopy Index your code
hub / github.com/numpy/numpy / test_binary_load

Method test_binary_load

numpy/lib/tests/test_io.py:1193–1207  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1191 @pytest.mark.skipif(locale.getpreferredencoding() == 'ANSI_X3.4-1968',
1192 reason="Wrong preferred encoding")
1193 def test_binary_load(self):
1194 butf8 = b"5,6,7,\xc3\x95scarscar\r\n15,2,3,hello\r\n"\
1195 b"20,2,3,\xc3\x95scar\r\n"
1196 sutf8 = butf8.decode("UTF-8").replace("\r", "").splitlines()
1197 with temppath() as path:
1198 with open(path, "wb") as f:
1199 f.write(butf8)
1200 with open(path, "rb") as f:
1201 x = np.loadtxt(f, encoding="UTF-8", dtype=np.str_)
1202 assert_array_equal(x, sutf8)
1203 # test broken latin1 conversion people now rely on
1204 with open(path, "rb") as f:
1205 x = np.loadtxt(f, encoding="UTF-8", dtype="S")
1206 x = [b'5,6,7,\xc3\x95scarscar', b'15,2,3,hello', b'20,2,3,\xc3\x95scar']
1207 assert_array_equal(x, np.array(x, dtype="S"))
1208
1209 def test_max_rows(self):
1210 c = TextIO()

Callers

nothing calls this directly

Calls 7

temppathFunction · 0.90
assert_array_equalFunction · 0.90
openFunction · 0.85
splitlinesMethod · 0.80
replaceMethod · 0.80
decodeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected