8000 MAINT: Stop using sixu instead of a u prefix · juliantaylor/numpy@91548b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 91548b5

Browse files
committed
MAINT: Stop using sixu instead of a u prefix
1 parent 09a21de commit 91548b5

File tree

11 files changed

+66
-73
lines changed

11 files changed

+66
-73
lines changed

numpy/core/tests/test_api.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import sys
44

55
import numpy as np
6-
from numpy.compat import sixu
76
from numpy.testing import (
87
run_module_suite, assert_, assert_equal, assert_array_equal,
98
assert_raises, HAS_REFCOUNT
@@ -248,7 +247,7 @@ def test_array_astype():
248247
b = a.astype('S')
249248
assert_equal(a, b)
250249
assert_equal(b.dtype, np.dtype('S100'))
251-
a = np.array([sixu('a')*100], dtype='O')
250+
a = np.array([u'a'*100], dtype='O')
252251
b = a.astype('U')
253252
assert_equal(a, b)
254253
assert_equal(b.dtype, np.dtype('U100'))
@@ -258,27 +257,27 @@ def test_array_astype():
258257
b = a.astype('S')
259258
assert_equal(a, b)
260259
assert_equal(b.dtype, np.dtype('S10'))
261-
a = np.array([sixu('a')*10], dtype='O')
260+
a = np.array([u'a'*10], dtype='O')
262261
b = a.astype('U')
263262
assert_equal(a, b)
264263
assert_equal(b.dtype, np.dtype('U10'))
265264

266265
a = np.array(123456789012345678901234567890, dtype='O').astype('S')
267266
assert_array_equal(a, np.array(b'1234567890' * 3, dtype='S30'))
268267
a = np.array(123456789012345678901234567890, dtype='O').astype('U')
269-
assert_array_equal(a, np.array(sixu('1234567890' * 3), dtype='U30'))
268+
assert_array_equal(a, np.array(u'1234567890' * 3, dtype='U30'))
270269

271270
a = np.array([123456789012345678901234567890], dtype='O').astype('S')
272271
assert_array_equal(a, np.array(b'1234567890' * 3, dtype='S30'))
273272
a = np.array([123456789012345678901234567890], dtype='O').astype('U')
274-
assert_array_equal(a, np.array(sixu('1234567890' * 3), dtype='U30'))
273+
assert_array_equal(a, np.array(u'1234567890' * 3, dtype='U30'))
275274

276275
a = np.array(123456789012345678901234567890, dtype='S')
277276
assert_array_equal(a, np.array(b'1234567890' * 3, dtype='S30'))
278277
a = np.array(123456789012345678901234567890, dtype='U')
279-
assert_array_equal(a, np.array(sixu('1234567890' * 3), dtype='U30'))
278+
assert_array_equal(a, np.array(u'1234567890' * 3, dtype='U30'))
280279

281-
a = np.array(sixu('a\u0140'), dtype='U')
280+
a = np.array(u'a\u0140', dtype='U')
282281
b = np.ndarray(buffer=a, dtype='uint32', shape=2)
283282
assert_(b.size == 2)
284283

numpy/core/tests/test_arrayprint.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import sys
55

66
import numpy as np
7-
from numpy.compat import sixu
87
from numpy.testing import (
98
TestCase, run_module_suite, assert_, assert_equal
109
)
@@ -223,7 +222,7 @@ def test_unicode_object_array():
223222
expected = "array(['é'], dtype=object)"
224223
else:
225224
expected = "array([u'\\xe9'], dtype=object)"
226-
x = np.array([sixu('\xe9')], dtype=object)
225+
x = np.array([u'\xe9'], dtype=object)
227226
assert_equal(repr(x), expected)
228227

229228

numpy/core/tests/test_defchararray.py

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import numpy as np
66
from numpy.core.multiarray import _vec_string
7-
from numpy.compat import sixu
87
from numpy.testing import (
98
TestCase, run_module_suite, assert_, assert_equal, assert_array_equal
109
)
@@ -22,12 +21,12 @@ def test_from_object_array(self):
2221
[b'long', b'0123456789']])
2322

2423
def test_from_object_array_unicode(self):
25-
A = np.array([['abc', sixu('Sigma \u03a3')],
24+
A = np.array([['abc', u'Sigma \u03a3'],
2625
['long ', '0123456789']], dtype='O')
2726
self.assertRaises(ValueError, np.char.array, (A,))
2827
B = np.char.array(A, **kw_unicode_true)
2928
assert_equal(B.dtype.itemsize, 10 * np.array('a', 'U').dtype.itemsize)
30-
assert_array_equal(B, [['abc', sixu('Sigma \u03a3')],
29+
assert_array_equal(B, [['abc', u'Sigma \u03a3'],
3130
['long', '0123456789']])
3231

3332
def test_from_string_array(self):
@@ -48,7 +47,7 @@ def test_from_string_array(self):
4847
assert_(C[0, 0] == A[0, 0])
4948

5049
def test_from_unicode_array(self):
51-
A = np.array([['abc', sixu('Sigma \u03a3')],
50+
A = np.array([['abc', u'Sigma \u03a3'],
5251
['long ', '0123456789']])
5352
assert_equal(A.dtype.type, np.unicode_)
5453
B = np.char.array(A)
@@ -67,7 +66,7 @@ def fail():
6766

6867
def test_unicode_upconvert(self):
6968
A = np.char.array(['abc'])
70-
B = np.char.array([sixu('\u03a3')])
69+
B = np.char.array([u'\u03a3'])
7170
assert_(issubclass((A + B).dtype.type, np.unicode_))
7271

7372
def test_from_string(self):
@@ -77,7 +76,7 @@ def test_from_string(self):
7776
assert_(issubclass(A.dtype.type, np.string_))
7877

7978
def test_from_unicode(self):
80-
A = np.char.array(sixu('\u03a3'))
79+
A = np.char.array(u'\u03a3')
8180
assert_equal(len(A), 1)
8281
assert_equal(len(A[0]), 1)
8382
assert_equal(A.itemsize, 4)
@@ -203,9 +202,9 @@ def setUp(self):
203202
self.A = np.array([[' abc ', ''],
204203
['12345', 'MixedCase'],
205204
['123 \t 345 \0 ', 'UPPER']]).view(np.chararray)
206-
self.B = np.array([[sixu(' \u03a3 '), sixu('')],
207-
[sixu('12345'), sixu('MixedCase')],
208-
[sixu('123 \t 345 \0 '), sixu('UPPER')]]).view(np.chararray)
205+
self.B = np.array([[u' \u03a3 ', u''],
206+
[u'12345', u'MixedCase'],
207+
[u'123 \t 345 \0 ', u'UPPER']]).view(np.chararray)
209208

210209
def test_len(self):
211210
assert_(issubclass(np.char.str_len(self.A).dtype.type, np.integer))
@@ -310,9 +309,9 @@ def setUp(self):
310309
['12345', 'MixedCase'],
311310
['123 \t 345 \0 ', 'UPPER']],
312311
dtype='S').view(np.chararray)
313-
self.B = np.array([[sixu(' \u03a3 '), sixu('')],
314-
[sixu('12345'), sixu('MixedCase')],
315-
[sixu('123 \t 345 \0 '), sixu('UPPER')]]).view(np.chararray)
312+
self.B = np.array([[u' \u03a3 ', u''],
313+
[u'12345', u'MixedCase'],
314+
[u'123 \t 345 \0 ', u'UPPER']]).view(np.chararray)
316315

317316
def test_capitalize(self):
318317
tgt = [[b' abc ', b''],
@@ -321,7 +320,7 @@ def test_capitalize(self):
321320
assert_(issubclass(self.A.capitalize().dtype.type, np.string_))
322321
assert_array_equal(self.A.capitalize(), tgt)
323322

324-
tgt = [[sixu(' \u03c3 '), ''],
323+
tgt = [[u' \u03c3 ', ''],
325324
['12345', 'Mixedcase'],
326325
['123 \t 345 \0 ', 'Upper']]
327326
assert_(issubclass(self.B.capitalize().dtype.type, np.unicode_))
@@ -400,9 +399,9 @@ def test_lower(self):
400399
assert_(issubclass(self.A.lower().dtype.type, np.string_))
401400
assert_array_equal(self.A.lower(), tgt)
402401

403-
tgt = [[sixu(' \u03c3 '), sixu('')],
404-
[sixu('12345'), sixu('mixedcase')],
405-
[sixu('123 \t 345 \0 '), sixu('upper')]]
402+
tgt = [[u' \u03c3 ', u''],
403+
[u'12345', u'mixedcase'],
404+
[u'123 \t 345 \0 ', u'upper']]
406405
assert_(issubclass(self.B.lower().dtype.type, np.unicode_))
407406
assert_array_equal(self.B.lower(), tgt)
408407

@@ -418,7 +417,7 @@ def test_lstrip(self):
418417
[b'23 \t 345 \x00', b'UPPER']]
419418
assert_array_equal(self.A.lstrip([b'1', b'M']), tgt)
420419

421-
tgt = [[sixu('\u03a3 '), ''],
420+
tgt = [[u'\u03a3 ', ''],
422421
['12345', 'MixedCase'],
423422
['123 \t 345 \0 ', 'UPPER']]
424423
assert_(issubclass(self.B.lstrip().dtype.type, np.unicode_))
@@ -443,9 +442,9 @@ def test_replace(self):
443442

444443
if sys.version_info[0] < 3:
445444
# NOTE: b'abc'.replace(b'a', 'b') is not allowed on Py3
446-
R = self.A.replace(b'a', sixu('\u03a3'))
447-
tgt = [[sixu(' \u03a3bc '), ''],
448-
['12345', sixu('MixedC\u03a3se')],
445+
R = self.A.replace(b'a', u'\u03a3')
446+
tgt = [[u' \u03a3bc ', ''],
447+
['12345', u'MixedC\u03a3se'],
449448
['123 \t 345 \x00', 'UPPER']]
450449
assert_(issubclass(R.dtype.type, np.unicode_))
451450
assert_array_equal(R, tgt)
@@ -497,7 +496,7 @@ def test_rstrip(self):
497496
]
498497
assert_array_equal(self.A.rstrip([b'5', b'ER']), tgt)
499498

500-
tgt = [[sixu(' \u03a3'), ''],
499+
tgt = [[u' \u03a3', ''],
501500
['12345', 'MixedCase'],
502501
['123 \t 345', 'UPPER']]
503502
assert_(issubclass(self.B.rstrip().dtype.type, np.unicode_))
@@ -515,7 +514,7 @@ def test_strip(self):
515514
[b'23 \t 345 \x00', b'UPP']]
516515
assert_array_equal(self.A.strip([b'15', b'EReM']), tgt)
517516

518-
tgt = [[sixu('\u03a3'), ''],
517+
tgt = [[u'\u03a3', ''],
519518
['12345', 'MixedCase'],
520519
['123 \t 345', 'UPPER']]
521520
assert_(issubclass(self.B.strip().dtype.type, np.unicode_))
@@ -543,9 +542,9 @@ def test_swapcase(self):
543542
assert_(issubclass(self.A.swapcase().dtype.type, np.string_))
544543
assert_array_equal(self.A.swapcase(), tgt)
545544

546-
tgt = [[sixu(' \u03c3 '), sixu('')],
547-
[sixu('12345'), sixu('mIXEDcASE')],
548-
[sixu('123 \t 345 \0 '), sixu('upper')]]
545+
tgt = [[u' \u03c3 ', u''],
546+
[u'12345', u'mIXEDcASE'],
547+
[u'123 \t 345 \0 ', u'upper']]
549548
assert_(issubclass(self.B.swapcase().dtype.type, np.unicode_))
550549
assert_array_equal(self.B.swapcase(), tgt)
551550

@@ -556,9 +555,9 @@ def test_title(self):
556555
assert_(issubclass(self.A.title().dtype.type, np.string_))
557556
assert_array_equal(self.A.title(), tgt)
558557

559-
tgt = [[sixu(' \u03a3 '), sixu('')],
560-
[sixu('12345'), sixu('Mixedcase')],
561-
[sixu('123 \t 345 \0 '), sixu('Upper')]]
558+
tgt = [[u' \u03a3 ', u''],
559+
[u'12345', u'Mixedcase'],
560+
[u'123 \t 345 \0 ', u'Upper']]
562561
assert_(issubclass(self.B.title().dtype.type, np.unicode_))
563562
assert_array_equal(self.B.title(), tgt)
564563

@@ -569,9 +568,9 @@ def test_upper(self):
569568
assert_(issubclass(self.A.upper().dtype.type, np.string_))
570569
assert_array_equal(self.A.upper(), tgt)
571570

572-
tgt = [[sixu(' \u03a3 '), sixu('')],
573-
[sixu('12345'), sixu('MIXEDCASE')],
574-
[sixu('123 \t 345 \0 '), sixu('UPPER')]]
571+
tgt = [[u' \u03a3 ', u''],
572+
[u'12345', u'MIXEDCASE'],
573+
[u'123 \t 345 \0 ', u'UPPER']]
575574
assert_(issubclass(self.B.upper().dtype.type, np.unicode_))
576575
assert_array_equal(self.B.upper(), tgt)
577576

numpy/core/tests/test_longdouble.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
run_module_suite, assert_, assert_equal, dec, assert_raises,
88
assert_array_equal, TestCase, temppath,
99
)
10-
from numpy.compat import sixu
1110
from test_print import in_foreign_locale
1211

1312
LD_INFO = np.finfo(np.longdouble)
@@ -40,7 +39,7 @@ def test_repr_roundtrip():
4039

4140

4241
def test_unicode():
43-
np.longdouble(sixu("1.2"))
42+
np.longdouble(u"1.2")
4443

4544

4645
def test_string():

numpy/core/tests/test_multiarray.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
import numpy as np
23-
from numpy.compat import getexception, strchar, unicode, sixu
23+
from numpy.compat import getexception, strchar, unicode
2424
from test_print import in_foreign_locale
2525
from numpy.core.multiarray_tests import (
2626
test_neighborhood_iterator, test_neighborhood_iterator_oob,
@@ -3278,8 +3278,8 @@ def test_mixed(self):
32783278
assert_array_equal(g1 >= g2, [x >= g2 for x in g1])
32793279

32803280
def test_unicode(self):
3281-
g1 = np.array([sixu("This"), sixu("is"), sixu("example")])
3282-
g2 = np.array([sixu("This"), sixu("was"), sixu("example")])
3281+
g1 = np.array([u"This", u"is", u"example"])
3282+
g2 = np.array([u"This", u"was", u"example"])
32833283
assert_array_equal(g1 == g2, [g1[i] == g2[i] for i in [0, 1, 2]])
32843284
assert_array_equal(g1 != g2, [g1[i] != g2[i] for i in [0, 1, 2]])
32853285
assert_array_equal(g1 <= g2, [g1[i] <= g2[i] for i in [0, 1, 2]])
@@ -4387,8 +4387,8 @@ def test_field_names(self):
43874387
raise SkipTest('non ascii unicode field indexing skipped; '
43884388
'raises segfault on python 2.x')
43894389
else:
4390-
assert_raises(ValueError, a.__setitem__, sixu('\u03e0'), 1)
4391-
assert_raises(ValueError, a.__getitem__, sixu('\u03e0'))
4390+
assert_raises(ValueError, a.__setitem__, u'\u03e0', 1)
4391+
assert_raises(ValueError, a.__getitem__, u'\u03e0')
43924392

43934393
def test_field_names_deprecation(self):
43944394

numpy/core/tests/test_nditer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import numpy as np
77
from numpy import array, arange, nditer, all
8-
from numpy.compat import sixu
98
from numpy.core.multiarray_tests import test_nditer_too_large
109
from numpy.testing import (
1110
run_module_suite, assert_, assert_equal, assert_array_equal,
@@ -2126,7 +2125,7 @@ def test_iter_buffering_string():
21262125
assert_raises(TypeError, nditer, a, ['buffered'], ['readonly'],
21272126
op_dtypes='U2')
21282127
i = nditer(a, ['buffered'], ['readonly'], op_dtypes='U6')
2129-
assert_equal(i[0], sixu('abc'))
2128+
assert_equal(i[0], u'abc')
21302129
assert_equal(i[0].dtype, np.dtype('U6'))
21312130

21322131
def test_iter_buffering_growinner():

numpy/core/tests/test_regression.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
assert_raises, assert_warns, dec, suppress_warnings
1919
)
2020
from numpy.testing.utils import _assert_valid_refcount, HAS_REFCOUNT
21-
from numpy.compat import asbytes, asunicode, long, sixu
21+
from numpy.compat import asbytes, asunicode, long
2222

2323
rlevel = 1
2424

@@ -146,7 +146,7 @@ def test_scalar_compare(self, level=rlevel):
146146
def test_unicode_swapping(self, level=rlevel):
147147
# Ticket #79
148148
ulen = 1
149-
ucs_value = sixu('\U0010FFFF')
149+
ucs_value = u'\U0010FFFF'
150150
ua = np.array([[[ucs_value*ulen]*2]*3]*4, dtype='U%s' % ulen)
151151
ua.newbyteorder() # Should succeed.
152152

@@ -1183,7 +1183,7 @@ def test_unaligned_unicode_access(self, level=rlevel):
11831183
for i in range(1, 9):
11841184
msg = 'unicode offset: %d chars' % i
11851185
t = np.dtype([('a', 'S%d' % i), ('b', 'U2')])
1186-
x = np.array([(b'a', sixu('b'))], dtype=t)
1186+
x = np.array([(b'a', u'b')], dtype=t)
11871187
if sys.version_info[0] >= 3:
11881188
assert_equal(str(x), "[(b'a', 'b')]", err_msg=msg)
11891189
else:
@@ -1377,21 +1377,21 @@ def test_object_array_to_fixed_string(self):
13771377

13781378
def test_unicode_to_string_cast(self):
13791379
# Ticket #1240.
1380-
a = np.array([[sixu('abc'), sixu('\u03a3')],
1381-
[sixu('asdf'), sixu('erw')]],
1380+
a = np.array([[u'abc', u'\u03a3'],
1381+
[u'asdf', u'erw']],
13821382
dtype='U')
13831383
self.assertRaises(UnicodeEncodeError, np.array, a, 'S4')
13841384

13851385
def test_mixed_string_unicode_array_creation(self):
1386-
a = np.array(['1234', sixu('123')])
1386+
a = np.array(['1234', u'123'])
13871387
assert_(a.itemsize == 16)
1388-
a = np.array([sixu('123'), '1234'])
1388+
a = np.array([u'123', '1234'])
13891389
assert_(a.itemsize == 16)
1390-
a = np.array(['1234', sixu('123'), '12345'])
1390+
a = np.array(['1234', u'123', '12345'])
13911391
assert_(a.itemsize == 20)
1392-
a = np.array([sixu('123'), '1234', sixu('12345')])
1392+
a = np.array([u'123', '1234', u'12345'])
13931393
assert_(a.itemsize == 20)
1394-
a = np.array([sixu('123'), '1234', sixu('1234')])
1394+
a = np.array([u'123', '1234', u'1234'])
13951395
assert_(a.itemsize == 16)
13961396

13971397
def test_misaligned_objects_segfault(self):
@@ -1973,7 +1973,7 @@ def test_string_truncation_ucs2(self):
19731973
if sys.version_info[0] >= 3:
19741974
a = np.array(['abcd'])
19751975
else:
1976-
a = np.array([sixu('abcd')])
1976+
a = np.array([u'abcd'])
19771977
assert_equal(a.dtype.itemsize, 16)
19781978

19791979
def test_unique_stable(self):
@@ -2042,8 +2042,8 @@ def test_fortran_order_buffer(self):
20422042
import numpy as np
20432043
a = np.array([['Hello', 'Foob']], dtype='U5', order='F')
20442044
arr = np.ndarray(shape=[1, 2, 5], dtype='U1', buffer=a)
2045-
arr2 = np.array([[[sixu('H'), sixu('e'), sixu('l'), sixu('l'), sixu('o')],
2046-
[sixu('F'), sixu('o'), sixu('o'), sixu('b'), sixu('')]]])
2045+
arr2 = np.array([[[u'H', u'e', u'l', u'l', u'o'],
2046+
[u'F', u'o', u'o', u'b', u'']]])
20472047
assert_array_equal(arr, arr2)
20482048

20492049
def test_assign_from_sequence_error(self):

0 commit comments

Comments
 (0)
0