diff options
author | Mike Taves <mwtoews@gmail.com> | 2022-10-27 06:02:37 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 10:02:37 -0700 |
commit | 13d55a3c2f016a58a6e9d6b8086f338e07c7478f (patch) | |
tree | a792928b2b4f959bdd685fba9dcf6ef7d049f145 /numpy/lib | |
parent | 12c2b7dd62fc0c14b81c8892ed5f4f59cc94d09c (diff) | |
download | numpy-13d55a3c2f016a58a6e9d6b8086f338e07c7478f.tar.gz |
MAINT: remove u-prefix for former Unicode strings (#22479)
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/tests/test_arraypad.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_format.py | 4 | ||||
-rw-r--r-- | numpy/lib/tests/test_io.py | 28 |
3 files changed, 17 insertions, 17 deletions
diff --git a/numpy/lib/tests/test_arraypad.py b/numpy/lib/tests/test_arraypad.py index 64b6a2e18..a59681573 100644 --- a/numpy/lib/tests/test_arraypad.py +++ b/numpy/lib/tests/test_arraypad.py @@ -1214,7 +1214,7 @@ def test_legacy_vector_functionality(): def test_unicode_mode(): - a = np.pad([1], 2, mode=u'constant') + a = np.pad([1], 2, mode='constant') b = np.array([0, 0, 1, 0, 0]) assert_array_equal(a, b) diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 3da59789d..08878a1f9 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -537,7 +537,7 @@ def test_pickle_python2_python3(): # Python 2 and Python 3 and vice versa data_dir = os.path.join(os.path.dirname(__file__), 'data') - expected = np.array([None, range, u'\u512a\u826f', + expected = np.array([None, range, '\u512a\u826f', b'\xe4\xb8\x8d\xe8\x89\xaf'], dtype=object) @@ -963,7 +963,7 @@ def test_unicode_field_names(tmpdir): (1, 2) ], dtype=[ ('int', int), - (u'\N{CJK UNIFIED IDEOGRAPH-6574}\N{CJK UNIFIED IDEOGRAPH-5F62}', int) + ('\N{CJK UNIFIED IDEOGRAPH-6574}\N{CJK UNIFIED IDEOGRAPH-5F62}', int) ]) fname = os.path.join(tmpdir, "unicode.npy") with open(fname, 'wb') as f: diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 0756cc646..b39db72eb 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -560,7 +560,7 @@ class TestSaveTxt: s.seek(0) assert_equal(s.read(), utf8 + '\n') - @pytest.mark.parametrize("fmt", [u"%f", b"%f"]) + @pytest.mark.parametrize("fmt", ["%f", b"%f"]) @pytest.mark.parametrize("iotype", [StringIO, BytesIO]) def test_unicode_and_bytes_fmt(self, fmt, iotype): # string type of fmt should not matter, see also gh-4053 @@ -569,7 +569,7 @@ class TestSaveTxt: np.savetxt(s, a, fmt=fmt) s.seek(0) if iotype is StringIO: - assert_equal(s.read(), u"%f\n" % 1.) + assert_equal(s.read(), "%f\n" % 1.) else: assert_equal(s.read(), b"%f\n" % 1.) @@ -763,7 +763,7 @@ class TestLoadTxt(LoadTxtBase): c.write('# comment\n1,2,3,5\n') c.seek(0) x = np.loadtxt(c, dtype=int, delimiter=',', - comments=u'#') + comments='#') a = np.array([1, 2, 3, 5], int) assert_array_equal(x, a) @@ -1514,7 +1514,7 @@ M 33 21.99 with tempdir() as tmpdir: fpath = os.path.join(tmpdir, "test.csv") with open(fpath, "wb") as f: - f.write(u'\N{GREEK PI SYMBOL}'.encode('utf8')) + f.write('\N{GREEK PI SYMBOL}'.encode()) # ResourceWarnings are emitted from a destructor, so won't be # detected by regular propagation to errors. @@ -2174,9 +2174,9 @@ M 33 21.99 test = np.genfromtxt(TextIO(s), dtype=None, comments=None, delimiter=',', encoding='latin1') - assert_equal(test[1, 0], u"test1") - assert_equal(test[1, 1], u"testNonethe" + latin1.decode('latin1')) - assert_equal(test[1, 2], u"test3") + assert_equal(test[1, 0], "test1") + assert_equal(test[1, 1], "testNonethe" + latin1.decode('latin1')) + assert_equal(test[1, 2], "test3") with warnings.catch_warnings(record=True) as w: warnings.filterwarnings('always', '', np.VisibleDeprecationWarning) @@ -2230,8 +2230,8 @@ M 33 21.99 def test_utf8_file_nodtype_unicode(self): # bytes encoding with non-latin1 -> unicode upcast - utf8 = u'\u03d6' - latin1 = u'\xf6\xfc\xf6' + utf8 = '\u03d6' + latin1 = '\xf6\xfc\xf6' # skip test if cannot encode utf8 test string with preferred # encoding. The preferred encoding is assumed to be the default @@ -2246,9 +2246,9 @@ M 33 21.99 with temppath() as path: with io.open(path, "wt") as f: - f.write(u"norm1,norm2,norm3\n") - f.write(u"norm1," + latin1 + u",norm3\n") - f.write(u"test1,testNonethe" + utf8 + u",test3\n") + f.write("norm1,norm2,norm3\n") + f.write("norm1," + latin1 + ",norm3\n") + f.write("test1,testNonethe" + utf8 + ",test3\n") with warnings.catch_warnings(record=True) as w: warnings.filterwarnings('always', '', np.VisibleDeprecationWarning) @@ -2583,7 +2583,7 @@ class TestPathUsage: with temppath(suffix='.txt') as path: path = Path(path) with path.open('w') as f: - f.write(u'A,B\n0,1\n2,3') + f.write('A,B\n0,1\n2,3') kwargs = dict(delimiter=",", missing_values="N/A", names=True) test = np.recfromtxt(path, **kwargs) @@ -2596,7 +2596,7 @@ class TestPathUsage: with temppath(suffix='.txt') as path: path = Path(path) with path.open('w') as f: - f.write(u'A,B\n0,1\n2,3') + f.write('A,B\n0,1\n2,3') kwargs = dict(missing_values="N/A", names=True, case_sensitive=True) test = np.recfromcsv(path, dtype=None, **kwargs) |