diff options
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test__iotools.py | 29 | ||||
-rw-r--r-- | numpy/lib/tests/test_format.py | 36 | ||||
-rw-r--r-- | numpy/lib/tests/test_twodim_base.py | 3 |
3 files changed, 33 insertions, 35 deletions
diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py index db3ee4f90..6c0b2c6db 100644 --- a/numpy/lib/tests/test__iotools.py +++ b/numpy/lib/tests/test__iotools.py @@ -5,7 +5,6 @@ import time from datetime import date import numpy as np -from numpy.compat import asbytes_nested from numpy.testing import ( run_module_suite, TestCase, assert_, assert_equal, assert_allclose, assert_raises @@ -23,59 +22,59 @@ class TestLineSplitter(TestCase): "Test LineSplitter w/o delimiter" strg = b" 1 2 3 4 5 # test" test = LineSplitter()(strg) - assert_equal(test, asbytes_nested(['1', '2', '3', '4', '5'])) + assert_equal(test, [b'1', b'2', b'3', b'4', b'5']) test = LineSplitter('')(strg) - assert_equal(test, asbytes_nested(['1', '2', '3', '4', '5'])) + assert_equal(test, [b'1', b'2', b'3', b'4', b'5']) def test_space_delimiter(self): "Test space delimiter" strg = b" 1 2 3 4 5 # test" test = LineSplitter(b' ')(strg) - assert_equal(test, asbytes_nested(['1', '2', '3', '4', '', '5'])) + assert_equal(test, [b'1', b'2', b'3', b'4', b'', b'5']) test = LineSplitter(b' ')(strg) - assert_equal(test, asbytes_nested(['1 2 3 4', '5'])) + assert_equal(test, [b'1 2 3 4', b'5']) def test_tab_delimiter(self): "Test tab delimiter" strg = b" 1\t 2\t 3\t 4\t 5 6" test = LineSplitter(b'\t')(strg) - assert_equal(test, asbytes_nested(['1', '2', '3', '4', '5 6'])) + assert_equal(test, [b'1', b'2', b'3', b'4', b'5 6']) strg = b" 1 2\t 3 4\t 5 6" test = LineSplitter(b'\t')(strg) - assert_equal(test, asbytes_nested(['1 2', '3 4', '5 6'])) + assert_equal(test, [b'1 2', b'3 4', b'5 6']) def test_other_delimiter(self): "Test LineSplitter on delimiter" strg = b"1,2,3,4,,5" test = LineSplitter(b',')(strg) - assert_equal(test, asbytes_nested(['1', '2', '3', '4', '', '5'])) + assert_equal(test, [b'1', b'2', b'3', b'4', b'', b'5']) # strg = b" 1,2,3,4,,5 # test" test = LineSplitter(b',')(strg) - assert_equal(test, asbytes_nested(['1', '2', '3', '4', '', '5'])) + assert_equal(test, [b'1', b'2', b'3', b'4', b'', b'5']) def test_constant_fixed_width(self): "Test LineSplitter w/ fixed-width fields" strg = b" 1 2 3 4 5 # test" test = LineSplitter(3)(strg) - assert_equal(test, asbytes_nested(['1', '2', '3', '4', '', '5', ''])) + assert_equal(test, [b'1', b'2', b'3', b'4', b'', b'5', b'']) # strg = b" 1 3 4 5 6# test" test = LineSplitter(20)(strg) - assert_equal(test, asbytes_nested(['1 3 4 5 6'])) + assert_equal(test, [b'1 3 4 5 6']) # strg = b" 1 3 4 5 6# test" test = LineSplitter(30)(strg) - assert_equal(test, asbytes_nested(['1 3 4 5 6'])) + assert_equal(test, [b'1 3 4 5 6']) def test_variable_fixed_width(self): strg = b" 1 3 4 5 6# test" test = LineSplitter((3, 6, 6, 3))(strg) - assert_equal(test, asbytes_nested(['1', '3', '4 5', '6'])) + assert_equal(test, [b'1', b'3', b'4 5', b'6']) # strg = b" 1 3 4 5 6# test" test = LineSplitter((6, 6, 9))(strg) - assert_equal(test, asbytes_nested(['1', '3 4', '5 6'])) + assert_equal(test, [b'1', b'3 4', b'5 6']) # ----------------------------------------------------------------------------- @@ -238,7 +237,7 @@ class TestStringConverter(TestCase): converter = StringConverter(int, default=0, missing_values=b"N/A") assert_equal( - converter.missing_values, set(asbytes_nested(['', 'N/A']))) + converter.missing_values, set([b'', b'N/A'])) def test_int64_dtype(self): "Check that int64 integer types can be specified" diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 77ac5942a..2dcb260c3 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -284,7 +284,7 @@ import warnings from io import BytesIO import numpy as np -from numpy.compat import asbytes_nested, sixu +from numpy.compat import sixu from numpy.testing import ( run_module_suite, assert_, assert_array_equal, assert_raises, raises, dec, SkipTest @@ -682,23 +682,23 @@ def test_write_version(): raise AssertionError("we should have raised a ValueError for the bad version %r" % (version,)) -bad_version_magic = asbytes_nested([ - '\x93NUMPY\x01\x01', - '\x93NUMPY\x00\x00', - '\x93NUMPY\x00\x01', - '\x93NUMPY\x02\x00', - '\x93NUMPY\x02\x02', - '\x93NUMPY\xff\xff', -]) -malformed_magic = asbytes_nested([ - '\x92NUMPY\x01\x00', - '\x00NUMPY\x01\x00', - '\x93numpy\x01\x00', - '\x93MATLB\x01\x00', - '\x93NUMPY\x01', - '\x93NUMPY', - '', -]) +bad_version_magic = [ + b'\x93NUMPY\x01\x01', + b'\x93NUMPY\x00\x00', + b'\x93NUMPY\x00\x01', + b'\x93NUMPY\x02\x00', + b'\x93NUMPY\x02\x02', + b'\x93NUMPY\xff\xff', +] +malformed_magic = [ + b'\x92NUMPY\x01\x00', + b'\x00NUMPY\x01\x00', + b'\x93numpy\x01\x00', + b'\x93MATLB\x01\x00', + b'\x93NUMPY\x01', + b'\x93NUMPY', + b'', +] def test_read_magic(): s1 = BytesIO() diff --git a/numpy/lib/tests/test_twodim_base.py b/numpy/lib/tests/test_twodim_base.py index 98b8aa39c..d57791e34 100644 --- a/numpy/lib/tests/test_twodim_base.py +++ b/numpy/lib/tests/test_twodim_base.py @@ -15,7 +15,6 @@ from numpy import ( ) import numpy as np -from numpy.compat import asbytes_nested def get_mat(n): @@ -91,7 +90,7 @@ class TestEye(TestCase): def test_strings(self): assert_equal(eye(2, 2, dtype='S3'), - asbytes_nested([['1', ''], ['', '1']])) + [[b'1', b''], [b'', b'1']]) def test_bool(self): assert_equal(eye(2, 2, dtype=bool), [[True, False], [False, True]]) |