summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/tests/test_api.py13
-rw-r--r--numpy/core/tests/test_arrayprint.py3
-rw-r--r--numpy/core/tests/test_defchararray.py61
-rw-r--r--numpy/core/tests/test_longdouble.py3
-rw-r--r--numpy/core/tests/test_multiarray.py10
-rw-r--r--numpy/core/tests/test_nditer.py3
-rw-r--r--numpy/core/tests/test_regression.py26
-rw-r--r--numpy/core/tests/test_unicode.py10
-rw-r--r--numpy/lib/tests/test_format.py3
-rw-r--r--numpy/ma/core.py4
-rw-r--r--numpy/ma/tests/test_regression.py3
11 files changed, 66 insertions, 73 deletions
diff --git a/numpy/core/tests/test_api.py b/numpy/core/tests/test_api.py
index 47030f0c0..10c2d5421 100644
--- a/numpy/core/tests/test_api.py
+++ b/numpy/core/tests/test_api.py
@@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function
import sys
import numpy as np
-from numpy.compat import sixu
from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_array_equal,
assert_raises, HAS_REFCOUNT
@@ -248,7 +247,7 @@ def test_array_astype():
b = a.astype('S')
assert_equal(a, b)
assert_equal(b.dtype, np.dtype('S100'))
- a = np.array([sixu('a')*100], dtype='O')
+ a = np.array([u'a'*100], dtype='O')
b = a.astype('U')
assert_equal(a, b)
assert_equal(b.dtype, np.dtype('U100'))
@@ -258,7 +257,7 @@ def test_array_astype():
b = a.astype('S')
assert_equal(a, b)
assert_equal(b.dtype, np.dtype('S10'))
- a = np.array([sixu('a')*10], dtype='O')
+ a = np.array([u'a'*10], dtype='O')
b = a.astype('U')
assert_equal(a, b)
assert_equal(b.dtype, np.dtype('U10'))
@@ -266,19 +265,19 @@ def test_array_astype():
a = np.array(123456789012345678901234567890, dtype='O').astype('S')
assert_array_equal(a, np.array(b'1234567890' * 3, dtype='S30'))
a = np.array(123456789012345678901234567890, dtype='O').astype('U')
- assert_array_equal(a, np.array(sixu('1234567890' * 3), dtype='U30'))
+ assert_array_equal(a, np.array(u'1234567890' * 3, dtype='U30'))
a = np.array([123456789012345678901234567890], dtype='O').astype('S')
assert_array_equal(a, np.array(b'1234567890' * 3, dtype='S30'))
a = np.array([123456789012345678901234567890], dtype='O').astype('U')
- assert_array_equal(a, np.array(sixu('1234567890' * 3), dtype='U30'))
+ assert_array_equal(a, np.array(u'1234567890' * 3, dtype='U30'))
a = np.array(123456789012345678901234567890, dtype='S')
assert_array_equal(a, np.array(b'1234567890' * 3, dtype='S30'))
a = np.array(123456789012345678901234567890, dtype='U')
- assert_array_equal(a, np.array(sixu('1234567890' * 3), dtype='U30'))
+ assert_array_equal(a, np.array(u'1234567890' * 3, dtype='U30'))
- a = np.array(sixu('a\u0140'), dtype='U')
+ a = np.array(u'a\u0140', dtype='U')
b = np.ndarray(buffer=a, dtype='uint32', shape=2)
assert_(b.size == 2)
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
index 607fa7010..396d7a613 100644
--- a/numpy/core/tests/test_arrayprint.py
+++ b/numpy/core/tests/test_arrayprint.py
@@ -4,7 +4,6 @@ from __future__ import division, absolute_import, print_function
import sys
import numpy as np
-from numpy.compat import sixu
from numpy.testing import (
TestCase, run_module_suite, assert_, assert_equal
)
@@ -223,7 +222,7 @@ def test_unicode_object_array():
expected = "array(['é'], dtype=object)"
else:
expected = "array([u'\\xe9'], dtype=object)"
- x = np.array([sixu('\xe9')], dtype=object)
+ x = np.array([u'\xe9'], dtype=object)
assert_equal(repr(x), expected)
diff --git a/numpy/core/tests/test_defchararray.py b/numpy/core/tests/test_defchararray.py
index 00fca3b2c..11d7c3b90 100644
--- a/numpy/core/tests/test_defchararray.py
+++ b/numpy/core/tests/test_defchararray.py
@@ -4,7 +4,6 @@ import sys
import numpy as np
from numpy.core.multiarray import _vec_string
-from numpy.compat import sixu
from numpy.testing import (
TestCase, run_module_suite, assert_, assert_equal, assert_array_equal
)
@@ -22,12 +21,12 @@ class TestBasic(TestCase):
[b'long', b'0123456789']])
def test_from_object_array_unicode(self):
- A = np.array([['abc', sixu('Sigma \u03a3')],
+ A = np.array([['abc', u'Sigma \u03a3'],
['long ', '0123456789']], dtype='O')
self.assertRaises(ValueError, np.char.array, (A,))
B = np.char.array(A, **kw_unicode_true)
assert_equal(B.dtype.itemsize, 10 * np.array('a', 'U').dtype.itemsize)
- assert_array_equal(B, [['abc', sixu('Sigma \u03a3')],
+ assert_array_equal(B, [['abc', u'Sigma \u03a3'],
['long', '0123456789']])
def test_from_string_array(self):
@@ -48,7 +47,7 @@ class TestBasic(TestCase):
assert_(C[0, 0] == A[0, 0])
def test_from_unicode_array(self):
- A = np.array([['abc', sixu('Sigma \u03a3')],
+ A = np.array([['abc', u'Sigma \u03a3'],
['long ', '0123456789']])
assert_equal(A.dtype.type, np.unicode_)
B = np.char.array(A)
@@ -67,7 +66,7 @@ class TestBasic(TestCase):
def test_unicode_upconvert(self):
A = np.char.array(['abc'])
- B = np.char.array([sixu('\u03a3')])
+ B = np.char.array([u'\u03a3'])
assert_(issubclass((A + B).dtype.type, np.unicode_))
def test_from_string(self):
@@ -77,7 +76,7 @@ class TestBasic(TestCase):
assert_(issubclass(A.dtype.type, np.string_))
def test_from_unicode(self):
- A = np.char.array(sixu('\u03a3'))
+ A = np.char.array(u'\u03a3')
assert_equal(len(A), 1)
assert_equal(len(A[0]), 1)
assert_equal(A.itemsize, 4)
@@ -203,9 +202,9 @@ class TestInformation(TestCase):
self.A = np.array([[' abc ', ''],
['12345', 'MixedCase'],
['123 \t 345 \0 ', 'UPPER']]).view(np.chararray)
- self.B = np.array([[sixu(' \u03a3 '), sixu('')],
- [sixu('12345'), sixu('MixedCase')],
- [sixu('123 \t 345 \0 '), sixu('UPPER')]]).view(np.chararray)
+ self.B = np.array([[u' \u03a3 ', u''],
+ [u'12345', u'MixedCase'],
+ [u'123 \t 345 \0 ', u'UPPER']]).view(np.chararray)
def test_len(self):
assert_(issubclass(np.char.str_len(self.A).dtype.type, np.integer))
@@ -310,9 +309,9 @@ class TestMethods(TestCase):
['12345', 'MixedCase'],
['123 \t 345 \0 ', 'UPPER']],
dtype='S').view(np.chararray)
- self.B = np.array([[sixu(' \u03a3 '), sixu('')],
- [sixu('12345'), sixu('MixedCase')],
- [sixu('123 \t 345 \0 '), sixu('UPPER')]]).view(np.chararray)
+ self.B = np.array([[u' \u03a3 ', u''],
+ [u'12345', u'MixedCase'],
+ [u'123 \t 345 \0 ', u'UPPER']]).view(np.chararray)
def test_capitalize(self):
tgt = [[b' abc ', b''],
@@ -321,7 +320,7 @@ class TestMethods(TestCase):
assert_(issubclass(self.A.capitalize().dtype.type, np.string_))
assert_array_equal(self.A.capitalize(), tgt)
- tgt = [[sixu(' \u03c3 '), ''],
+ tgt = [[u' \u03c3 ', ''],
['12345', 'Mixedcase'],
['123 \t 345 \0 ', 'Upper']]
assert_(issubclass(self.B.capitalize().dtype.type, np.unicode_))
@@ -400,9 +399,9 @@ class TestMethods(TestCase):
assert_(issubclass(self.A.lower().dtype.type, np.string_))
assert_array_equal(self.A.lower(), tgt)
- tgt = [[sixu(' \u03c3 '), sixu('')],
- [sixu('12345'), sixu('mixedcase')],
- [sixu('123 \t 345 \0 '), sixu('upper')]]
+ tgt = [[u' \u03c3 ', u''],
+ [u'12345', u'mixedcase'],
+ [u'123 \t 345 \0 ', u'upper']]
assert_(issubclass(self.B.lower().dtype.type, np.unicode_))
assert_array_equal(self.B.lower(), tgt)
@@ -418,7 +417,7 @@ class TestMethods(TestCase):
[b'23 \t 345 \x00', b'UPPER']]
assert_array_equal(self.A.lstrip([b'1', b'M']), tgt)
- tgt = [[sixu('\u03a3 '), ''],
+ tgt = [[u'\u03a3 ', ''],
['12345', 'MixedCase'],
['123 \t 345 \0 ', 'UPPER']]
assert_(issubclass(self.B.lstrip().dtype.type, np.unicode_))
@@ -443,9 +442,9 @@ class TestMethods(TestCase):
if sys.version_info[0] < 3:
# NOTE: b'abc'.replace(b'a', 'b') is not allowed on Py3
- R = self.A.replace(b'a', sixu('\u03a3'))
- tgt = [[sixu(' \u03a3bc '), ''],
- ['12345', sixu('MixedC\u03a3se')],
+ R = self.A.replace(b'a', u'\u03a3')
+ tgt = [[u' \u03a3bc ', ''],
+ ['12345', u'MixedC\u03a3se'],
['123 \t 345 \x00', 'UPPER']]
assert_(issubclass(R.dtype.type, np.unicode_))
assert_array_equal(R, tgt)
@@ -497,7 +496,7 @@ class TestMethods(TestCase):
]
assert_array_equal(self.A.rstrip([b'5', b'ER']), tgt)
- tgt = [[sixu(' \u03a3'), ''],
+ tgt = [[u' \u03a3', ''],
['12345', 'MixedCase'],
['123 \t 345', 'UPPER']]
assert_(issubclass(self.B.rstrip().dtype.type, np.unicode_))
@@ -515,7 +514,7 @@ class TestMethods(TestCase):
[b'23 \t 345 \x00', b'UPP']]
assert_array_equal(self.A.strip([b'15', b'EReM']), tgt)
- tgt = [[sixu('\u03a3'), ''],
+ tgt = [[u'\u03a3', ''],
['12345', 'MixedCase'],
['123 \t 345', 'UPPER']]
assert_(issubclass(self.B.strip().dtype.type, np.unicode_))
@@ -543,9 +542,9 @@ class TestMethods(TestCase):
assert_(issubclass(self.A.swapcase().dtype.type, np.string_))
assert_array_equal(self.A.swapcase(), tgt)
- tgt = [[sixu(' \u03c3 '), sixu('')],
- [sixu('12345'), sixu('mIXEDcASE')],
- [sixu('123 \t 345 \0 '), sixu('upper')]]
+ tgt = [[u' \u03c3 ', u''],
+ [u'12345', u'mIXEDcASE'],
+ [u'123 \t 345 \0 ', u'upper']]
assert_(issubclass(self.B.swapcase().dtype.type, np.unicode_))
assert_array_equal(self.B.swapcase(), tgt)
@@ -556,9 +555,9 @@ class TestMethods(TestCase):
assert_(issubclass(self.A.title().dtype.type, np.string_))
assert_array_equal(self.A.title(), tgt)
- tgt = [[sixu(' \u03a3 '), sixu('')],
- [sixu('12345'), sixu('Mixedcase')],
- [sixu('123 \t 345 \0 '), sixu('Upper')]]
+ tgt = [[u' \u03a3 ', u''],
+ [u'12345', u'Mixedcase'],
+ [u'123 \t 345 \0 ', u'Upper']]
assert_(issubclass(self.B.title().dtype.type, np.unicode_))
assert_array_equal(self.B.title(), tgt)
@@ -569,9 +568,9 @@ class TestMethods(TestCase):
assert_(issubclass(self.A.upper().dtype.type, np.string_))
assert_array_equal(self.A.upper(), tgt)
- tgt = [[sixu(' \u03a3 '), sixu('')],
- [sixu('12345'), sixu('MIXEDCASE')],
- [sixu('123 \t 345 \0 '), sixu('UPPER')]]
+ tgt = [[u' \u03a3 ', u''],
+ [u'12345', u'MIXEDCASE'],
+ [u'123 \t 345 \0 ', u'UPPER']]
assert_(issubclass(self.B.upper().dtype.type, np.unicode_))
assert_array_equal(self.B.upper(), tgt)
diff --git a/numpy/core/tests/test_longdouble.py b/numpy/core/tests/test_longdouble.py
index 0c363a8c3..eda52c90a 100644
--- a/numpy/core/tests/test_longdouble.py
+++ b/numpy/core/tests/test_longdouble.py
@@ -7,7 +7,6 @@ from numpy.testing import (
run_module_suite, assert_, assert_equal, dec, assert_raises,
assert_array_equal, TestCase, temppath,
)
-from numpy.compat import sixu
from test_print import in_foreign_locale
LD_INFO = np.finfo(np.longdouble)
@@ -40,7 +39,7 @@ def test_repr_roundtrip():
def test_unicode():
- np.longdouble(sixu("1.2"))
+ np.longdouble(u"1.2")
def test_string():
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index ac84014a9..9f4aca087 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -20,7 +20,7 @@ from decimal import Decimal
import numpy as np
-from numpy.compat import getexception, strchar, unicode, sixu
+from numpy.compat import getexception, strchar, unicode
from test_print import in_foreign_locale
from numpy.core.multiarray_tests import (
test_neighborhood_iterator, test_neighborhood_iterator_oob,
@@ -3278,8 +3278,8 @@ class TestStringCompare(TestCase):
assert_array_equal(g1 >= g2, [x >= g2 for x in g1])
def test_unicode(self):
- g1 = np.array([sixu("This"), sixu("is"), sixu("example")])
- g2 = np.array([sixu("This"), sixu("was"), sixu("example")])
+ g1 = np.array([u"This", u"is", u"example"])
+ g2 = np.array([u"This", u"was", u"example"])
assert_array_equal(g1 == g2, [g1[i] == g2[i] for i in [0, 1, 2]])
assert_array_equal(g1 != g2, [g1[i] != g2[i] for i in [0, 1, 2]])
assert_array_equal(g1 <= g2, [g1[i] <= g2[i] for i in [0, 1, 2]])
@@ -4387,8 +4387,8 @@ class TestRecord(TestCase):
raise SkipTest('non ascii unicode field indexing skipped; '
'raises segfault on python 2.x')
else:
- assert_raises(ValueError, a.__setitem__, sixu('\u03e0'), 1)
- assert_raises(ValueError, a.__getitem__, sixu('\u03e0'))
+ assert_raises(ValueError, a.__setitem__, u'\u03e0', 1)
+ assert_raises(ValueError, a.__getitem__, u'\u03e0')
def test_field_names_deprecation(self):
diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py
index 5ff4468e9..2e37fc5da 100644
--- a/numpy/core/tests/test_nditer.py
+++ b/numpy/core/tests/test_nditer.py
@@ -5,7 +5,6 @@ import warnings
import numpy as np
from numpy import array, arange, nditer, all
-from numpy.compat import sixu
from numpy.core.multiarray_tests import test_nditer_too_large
from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_array_equal,
@@ -2126,7 +2125,7 @@ def test_iter_buffering_string():
assert_raises(TypeError, nditer, a, ['buffered'], ['readonly'],
op_dtypes='U2')
i = nditer(a, ['buffered'], ['readonly'], op_dtypes='U6')
- assert_equal(i[0], sixu('abc'))
+ assert_equal(i[0], u'abc')
assert_equal(i[0].dtype, np.dtype('U6'))
def test_iter_buffering_growinner():
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index def80694a..264b30927 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -18,7 +18,7 @@ from numpy.testing import (
assert_raises, assert_warns, dec, suppress_warnings
)
from numpy.testing.utils import _assert_valid_refcount, HAS_REFCOUNT
-from numpy.compat import asbytes, asunicode, long, sixu
+from numpy.compat import asbytes, asunicode, long
rlevel = 1
@@ -146,7 +146,7 @@ class TestRegression(TestCase):
def test_unicode_swapping(self, level=rlevel):
# Ticket #79
ulen = 1
- ucs_value = sixu('\U0010FFFF')
+ ucs_value = u'\U0010FFFF'
ua = np.array([[[ucs_value*ulen]*2]*3]*4, dtype='U%s' % ulen)
ua.newbyteorder() # Should succeed.
@@ -1183,7 +1183,7 @@ class TestRegression(TestCase):
for i in range(1, 9):
msg = 'unicode offset: %d chars' % i
t = np.dtype([('a', 'S%d' % i), ('b', 'U2')])
- x = np.array([(b'a', sixu('b'))], dtype=t)
+ x = np.array([(b'a', u'b')], dtype=t)
if sys.version_info[0] >= 3:
assert_equal(str(x), "[(b'a', 'b')]", err_msg=msg)
else:
@@ -1377,21 +1377,21 @@ class TestRegression(TestCase):
def test_unicode_to_string_cast(self):
# Ticket #1240.
- a = np.array([[sixu('abc'), sixu('\u03a3')],
- [sixu('asdf'), sixu('erw')]],
+ a = np.array([[u'abc', u'\u03a3'],
+ [u'asdf', u'erw']],
dtype='U')
self.assertRaises(UnicodeEncodeError, np.array, a, 'S4')
def test_mixed_string_unicode_array_creation(self):
- a = np.array(['1234', sixu('123')])
+ a = np.array(['1234', u'123'])
assert_(a.itemsize == 16)
- a = np.array([sixu('123'), '1234'])
+ a = np.array([u'123', '1234'])
assert_(a.itemsize == 16)
- a = np.array(['1234', sixu('123'), '12345'])
+ a = np.array(['1234', u'123', '12345'])
assert_(a.itemsize == 20)
- a = np.array([sixu('123'), '1234', sixu('12345')])
+ a = np.array([u'123', '1234', u'12345'])
assert_(a.itemsize == 20)
- a = np.array([sixu('123'), '1234', sixu('1234')])
+ a = np.array([u'123', '1234', u'1234'])
assert_(a.itemsize == 16)
def test_misaligned_objects_segfault(self):
@@ -1973,7 +1973,7 @@ class TestRegression(TestCase):
if sys.version_info[0] >= 3:
a = np.array(['abcd'])
else:
- a = np.array([sixu('abcd')])
+ a = np.array([u'abcd'])
assert_equal(a.dtype.itemsize, 16)
def test_unique_stable(self):
@@ -2042,8 +2042,8 @@ class TestRegression(TestCase):
import numpy as np
a = np.array([['Hello', 'Foob']], dtype='U5', order='F')
arr = np.ndarray(shape=[1, 2, 5], dtype='U1', buffer=a)
- arr2 = np.array([[[sixu('H'), sixu('e'), sixu('l'), sixu('l'), sixu('o')],
- [sixu('F'), sixu('o'), sixu('o'), sixu('b'), sixu('')]]])
+ arr2 = np.array([[[u'H', u'e', u'l', u'l', u'o'],
+ [u'F', u'o', u'o', u'b', u'']]])
assert_array_equal(arr, arr2)
def test_assign_from_sequence_error(self):
diff --git a/numpy/core/tests/test_unicode.py b/numpy/core/tests/test_unicode.py
index a28d8dafa..ae2beb2a6 100644
--- a/numpy/core/tests/test_unicode.py
+++ b/numpy/core/tests/test_unicode.py
@@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function
import sys
import numpy as np
-from numpy.compat import unicode, sixu
+from numpy.compat import unicode
from numpy.testing import (
TestCase, run_module_suite, assert_, assert_equal, assert_array_equal)
@@ -32,7 +32,7 @@ if sys.version_info[:2] >= (3, 3):
else:
return np.prod(v.shape) * v.itemsize
else:
- if len(buffer(sixu('u'))) == 4:
+ if len(buffer(u'u')) == 4:
ucs4 = True
else:
ucs4 = False
@@ -45,9 +45,9 @@ else:
# In both cases below we need to make sure that the byte swapped value (as
# UCS4) is still a valid unicode:
# Value that can be represented in UCS2 interpreters
-ucs2_value = sixu('\u0900')
+ucs2_value = u'\u0900'
# Value that cannot be represented in UCS2 interpreters (but can in UCS4)
-ucs4_value = sixu('\U00100900')
+ucs4_value = u'\U00100900'
def test_string_cast():
@@ -78,7 +78,7 @@ class create_zeros(object):
# Check the length of the data buffer
self.assertTrue(buffer_length(ua) == nbytes)
# Small check that data in array element is ok
- self.assertTrue(ua_scalar == sixu(''))
+ self.assertTrue(ua_scalar == u'')
# Encode to ascii and double check
self.assertTrue(ua_scalar.encode('ascii') == b'')
# Check buffer lengths for scalars
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py
index 2dcb260c3..93727ef0c 100644
--- a/numpy/lib/tests/test_format.py
+++ b/numpy/lib/tests/test_format.py
@@ -284,7 +284,6 @@ import warnings
from io import BytesIO
import numpy as np
-from numpy.compat import sixu
from numpy.testing import (
run_module_suite, assert_, assert_array_equal, assert_raises, raises,
dec, SkipTest
@@ -545,7 +544,7 @@ def test_pickle_python2_python3():
import __builtin__
xrange = __builtin__.xrange
- expected = np.array([None, xrange, sixu('\u512a\u826f'),
+ expected = np.array([None, xrange, u'\u512a\u826f',
b'\xe4\xb8\x8d\xe8\x89\xaf'],
dtype=object)
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index e78d1601d..ca233ca9f 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -39,7 +39,7 @@ from numpy import ndarray, amax, amin, iscomplexobj, bool_, _NoValue
from numpy import array as narray
from numpy.lib.function_base import angle
from numpy.compat import (
- getargspec, formatargspec, long, basestring, unicode, bytes, sixu
+ getargspec, formatargspec, long, basestring, unicode, bytes
)
from numpy import expand_dims as n_expand_dims
from numpy.core.multiarray import normalize_axis_index
@@ -159,7 +159,7 @@ default_filler = {'b': True,
'S': b'N/A',
'u': 999999,
'V': '???',
- 'U': sixu('N/A')
+ 'U': u'N/A'
}
# Add datetime64 and timedelta64 types
diff --git a/numpy/ma/tests/test_regression.py b/numpy/ma/tests/test_regression.py
index fc6cdfaff..d1fb2bb2b 100644
--- a/numpy/ma/tests/test_regression.py
+++ b/numpy/ma/tests/test_regression.py
@@ -6,7 +6,6 @@ import numpy as np
from numpy.testing import (assert_, TestCase, assert_array_equal,
assert_allclose, run_module_suite,
suppress_warnings)
-from numpy.compat import sixu
rlevel = 1
@@ -44,7 +43,7 @@ class TestRegression(TestCase):
def test_masked_array_repr_unicode(self):
# Ticket #1256
- repr(np.ma.array(sixu("Unicode")))
+ repr(np.ma.array(u"Unicode"))
def test_atleast_2d(self):
# Ticket #1559