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

Method test_unicode_roundtrip

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

Source from the content-addressed store, hash-verified

555 encoding='UTF-8')
556
557 def test_unicode_roundtrip(self):
558 utf8 = b'\xcf\x96'.decode('UTF-8')
559 a = np.array([utf8], dtype=np.str_)
560 # our gz wrapper support encoding
561 suffixes = ['', '.gz']
562 if HAS_BZ2:
563 suffixes.append('.bz2')
564 if HAS_LZMA:
565 suffixes.extend(['.xz', '.lzma'])
566 with tempdir() as tmpdir:
567 for suffix in suffixes:
568 np.savetxt(os.path.join(tmpdir, 'test.csv' + suffix), a,
569 fmt=['%s'], encoding='UTF-16-LE')
570 b = np.loadtxt(os.path.join(tmpdir, 'test.csv' + suffix),
571 encoding='UTF-16-LE', dtype=np.str_)
572 assert_array_equal(a, b)
573
574 def test_unicode_bytestream(self):
575 utf8 = b'\xcf\x96'.decode('UTF-8')

Callers

nothing calls this directly

Calls 4

tempdirFunction · 0.90
assert_array_equalFunction · 0.90
decodeMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected