[Numpy-svn] r8209 - trunk/numpy/lib/tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Sat Feb 20 21:49:04 EST 2010
Author: ptvirtan
Date: 2010-02-20 20:49:04 -0600 (Sat, 20 Feb 2010)
New Revision: 8209
Modified:
trunk/numpy/lib/tests/test_io.py
trunk/numpy/lib/tests/test_twodim_base.py
Log:
3K: lib: fix bytes vs str issues in tests
Modified: trunk/numpy/lib/tests/test_io.py
===================================================================
--- trunk/numpy/lib/tests/test_io.py 2010-02-21 02:48:47 UTC (rev 8208)
+++ trunk/numpy/lib/tests/test_io.py 2010-02-21 02:49:04 UTC (rev 8209)
@@ -15,7 +15,7 @@
from numpy.lib._iotools import ConverterError, ConverterLockError, \
ConversionWarning
-from numpy.compat import asbytes, asbytes_nested
+from numpy.compat import asbytes, asbytes_nested, bytes
if sys.version_info[0] >= 3:
from io import BytesIO
@@ -171,8 +171,9 @@
np.savetxt(c, a, fmt=fmt)
c.seek(0)
assert_equal(c.readlines(),
- [(fmt + ' ' + fmt + '\n') % (1, 2),
- (fmt + ' ' + fmt + '\n') % (3, 4)])
+ asbytes_nested(
+ [(fmt + ' ' + fmt + '\n') % (1, 2),
+ (fmt + ' ' + fmt + '\n') % (3, 4)]))
a = np.array([[1, 2], [3, 4]], int)
c = StringIO()
@@ -186,7 +187,7 @@
np.savetxt(c, a, fmt='%d')
c.seek(0)
lines = c.readlines()
- assert_equal(lines, ['1\n', '2\n', '3\n', '4\n'])
+ assert_equal(lines, asbytes_nested(['1\n', '2\n', '3\n', '4\n']))
def test_record(self):
a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
@@ -200,7 +201,7 @@
c = StringIO()
np.savetxt(c, a, delimiter=asbytes(','), fmt='%d')
c.seek(0)
- assert_equal(c.readlines(), ['1,2\n', '3,4\n'])
+ assert_equal(c.readlines(), asbytes_nested(['1,2\n', '3,4\n']))
def test_format(self):
a = np.array([(1, 2), (3, 4)])
@@ -667,7 +668,7 @@
def test_dtype_with_converters(self):
dstr = "2009; 23; 46"
test = np.ndfromtxt(StringIO(dstr,),
- delimiter=";", dtype=float, converters={0:str})
+ delimiter=";", dtype=float, converters={0:bytes})
control = np.array([('2009', 23., 46)],
dtype=[('f0', '|S4'), ('f1', float), ('f2', float)])
assert_equal(test, control)
@@ -709,7 +710,7 @@
"Test user_converters w/ explicit (standard) dtype"
data = StringIO('skip,skip,2001-01-01,1.0,skip')
test = np.genfromtxt(data, delimiter=",", names=None, dtype=float,
- usecols=(2, 3), converters={2: str})
+ usecols=(2, 3), converters={2: bytes})
control = np.array([('2001-01-01', 1.)],
dtype=[('', '|S10'), ('', float)])
assert_equal(test, control)
Modified: trunk/numpy/lib/tests/test_twodim_base.py
===================================================================
--- trunk/numpy/lib/tests/test_twodim_base.py 2010-02-21 02:48:47 UTC (rev 8208)
+++ trunk/numpy/lib/tests/test_twodim_base.py 2010-02-21 02:49:04 UTC (rev 8209)
@@ -9,6 +9,7 @@
triu_indices_from, tril_indices, tril_indices_from )
import numpy as np
+from numpy.compat import asbytes, asbytes_nested
def get_mat(n):
data = arange(n)
@@ -65,7 +66,8 @@
assert_equal(eye(3, 2, -3), [[0, 0], [0, 0], [0, 0]])
def test_strings(self):
- assert_equal(eye(2, 2, dtype='S3'), [['1', ''], ['', '1']])
+ assert_equal(eye(2, 2, dtype='S3'),
+ asbytes_nested([['1', ''], ['', '1']]))
def test_bool(self):
assert_equal(eye(2, 2, dtype=bool), [[True, False], [False, True]])
More information about the Numpy-svn
mailing list