MCPcopy Create free account
hub / github.com/numpy/numpy / test_binary_load

Method test_binary_load

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

Source from the content-addressed store, hash-verified

1180 @pytest.mark.skipif(locale.getpreferredencoding() == 'ANSI_X3.4-1968',
1181 reason="Wrong preferred encoding")
1182 def test_binary_load(self):
1183 butf8 = b"5,6,7,\xc3\x95scarscar\r\n15,2,3,hello\r\n"\
1184 b"20,2,3,\xc3\x95scar\r\n"
1185 sutf8 = butf8.decode("UTF-8").replace("\r", "").splitlines()
1186 with temppath() as path:
1187 with open(path, "wb") as f:
1188 f.write(butf8)
1189 with open(path, "rb") as f:
1190 x = np.loadtxt(f, encoding="UTF-8", dtype=np.str_)
1191 assert_array_equal(x, sutf8)
1192 # test broken latin1 conversion people now rely on
1193 with open(path, "rb") as f:
1194 x = np.loadtxt(f, encoding="UTF-8", dtype="S")
1195 x = [b'5,6,7,\xc3\x95scarscar', b'15,2,3,hello', b'20,2,3,\xc3\x95scar']
1196 assert_array_equal(x, np.array(x, dtype="S"))
1197
1198 def test_max_rows(self):
1199 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