summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Homeier <derek@astro.physik.uni-goettingen.de>2011-06-13 16:59:50 +0200
committerMark Wiebe <mwiebe@enthought.com>2011-06-16 14:22:18 -0500
commite9f4e7592ae24e220bfcd0489b4bb25b9c2fc8e7 (patch)
tree0ae5d55ef1992a3d5a41344594b80b8c751e65e9
parentafe25c18c0c42cc4281068e3c91d471176b7b11d (diff)
downloadnumpy-e9f4e7592ae24e220bfcd0489b4bb25b9c2fc8e7.tar.gz
BUG: Py3k: some of the string type-related failures in numpy/core/tests
MW: I've removed the asbytes part and changed 'S5' to 'S0' from Derek's original commit.
-rw-r--r--numpy/core/tests/test_arrayprint.py2
-rw-r--r--numpy/core/tests/test_datetime.py30
-rw-r--r--numpy/core/tests/test_regression.py2
3 files changed, 17 insertions, 17 deletions
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
index b1dbb1d68..5588d244a 100644
--- a/numpy/core/tests/test_arrayprint.py
+++ b/numpy/core/tests/test_arrayprint.py
@@ -82,7 +82,7 @@ class TestArray2String(TestCase):
"[. o O]")
assert_(np.array2string(x, formatter={'all':lambda x: "%.4f" % x}) == \
"[0.0000 1.0000 2.0000]")
- assert_(np.array2string(x, formatter={'int':lambda x: hex(x)}) == \
+ assert_equal(np.array2string(x, formatter={'int':lambda x: hex(x)}), \
"[0x0L 0x1L 0x2L]")
x = np.arange(3.)
diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py
index d14b4bc07..b51febb85 100644
--- a/numpy/core/tests/test_datetime.py
+++ b/numpy/core/tests/test_datetime.py
@@ -116,7 +116,7 @@ class TestDateTime(TestCase):
assert_equal(a.dtype, np.dtype('M8[h]'))
assert_equal(b.dtype, np.dtype('M8[h]'))
- assert_equal(np.datetime64(a), a);
+ assert_equal(np.datetime64(a), a)
assert_equal(np.datetime64(a).dtype, np.dtype('M8[h]'))
assert_equal(np.datetime64(b), a)
@@ -159,7 +159,7 @@ class TestDateTime(TestCase):
assert_equal(a.dtype, np.dtype('m8[h]'))
assert_equal(b.dtype, np.dtype('m8[h]'))
- assert_equal(np.timedelta64(a), a);
+ assert_equal(np.timedelta64(a), a)
assert_equal(np.timedelta64(a).dtype, np.dtype('m8[h]'))
assert_equal(np.timedelta64(b), a)
@@ -312,9 +312,9 @@ class TestDateTime(TestCase):
assert_equal(np.array('1601', dtype='M8[D]').astype('i8'),
(1600-1970)*365 - (1972-1600)/4 + 3 + 366)
assert_equal(np.array('1900', dtype='M8[D]').astype('i8'),
- (1900-1970)*365 - (1970-1900)/4)
+ (1900-1970)*365 - (1970-1900)//4)
assert_equal(np.array('1901', dtype='M8[D]').astype('i8'),
- (1900-1970)*365 - (1970-1900)/4 + 365)
+ (1900-1970)*365 - (1970-1900)//4 + 365)
assert_equal(np.array('1967', dtype='M8[D]').astype('i8'), -3*365 - 1)
assert_equal(np.array('1968', dtype='M8[D]').astype('i8'), -2*365 - 1)
assert_equal(np.array('1969', dtype='M8[D]').astype('i8'), -1*365)
@@ -324,24 +324,24 @@ class TestDateTime(TestCase):
assert_equal(np.array('1973', dtype='M8[D]').astype('i8'), 3*365 + 1)
assert_equal(np.array('1974', dtype='M8[D]').astype('i8'), 4*365 + 1)
assert_equal(np.array('2000', dtype='M8[D]').astype('i8'),
- (2000 - 1970)*365 + (2000 - 1972)/4)
+ (2000 - 1970)*365 + (2000 - 1972)//4)
assert_equal(np.array('2001', dtype='M8[D]').astype('i8'),
- (2000 - 1970)*365 + (2000 - 1972)/4 + 366)
+ (2000 - 1970)*365 + (2000 - 1972)//4 + 366)
assert_equal(np.array('2400', dtype='M8[D]').astype('i8'),
- (2400 - 1970)*365 + (2400 - 1972)/4 - 3)
+ (2400 - 1970)*365 + (2400 - 1972)//4 - 3)
assert_equal(np.array('2401', dtype='M8[D]').astype('i8'),
- (2400 - 1970)*365 + (2400 - 1972)/4 - 3 + 366)
+ (2400 - 1970)*365 + (2400 - 1972)//4 - 3 + 366)
assert_equal(np.array('1600-02-29', dtype='M8[D]').astype('i8'),
- (1600-1970)*365 - (1972-1600)/4 + 3 + 31 + 28)
+ (1600-1970)*365 - (1972-1600)//4 + 3 + 31 + 28)
assert_equal(np.array('1600-03-01', dtype='M8[D]').astype('i8'),
- (1600-1970)*365 - (1972-1600)/4 + 3 + 31 + 29)
+ (1600-1970)*365 - (1972-1600)//4 + 3 + 31 + 29)
assert_equal(np.array('2000-02-29', dtype='M8[D]').astype('i8'),
- (2000 - 1970)*365 + (2000 - 1972)/4 + 31 + 28)
+ (2000 - 1970)*365 + (2000 - 1972)//4 + 31 + 28)
assert_equal(np.array('2000-03-01', dtype='M8[D]').astype('i8'),
- (2000 - 1970)*365 + (2000 - 1972)/4 + 31 + 29)
+ (2000 - 1970)*365 + (2000 - 1972)//4 + 31 + 29)
assert_equal(np.array('2001-03-22', dtype='M8[D]').astype('i8'),
- (2000 - 1970)*365 + (2000 - 1972)/4 + 366 + 31 + 28 + 21)
+ (2000 - 1970)*365 + (2000 - 1972)//4 + 366 + 31 + 28 + 21)
def test_days_to_pydate(self):
assert_equal(np.array('1599', dtype='M8[D]').astype('O'),
@@ -1020,7 +1020,7 @@ class TestDateTime(TestCase):
date = '1969-12-31T23:59:57.789012345678901234Z'
assert_equal(np.datetime_as_string(np.datetime64(date, 'as')),
- date);
+ date)
date = '1970-01-01T00:34:56.789012345678901234Z'
assert_equal(np.datetime_as_string(np.datetime64(date, 'ns')),
@@ -1033,7 +1033,7 @@ class TestDateTime(TestCase):
date = '1970-01-01T00:00:05.789012345678901234Z'
assert_equal(np.datetime_as_string(np.datetime64(date, 'as')),
- date);
+ date)
# String conversion with the unit= parameter
a = np.datetime64('2032-07-18T12:23:34.123456Z', 'us')
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 764bf9a41..5db874ecd 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -1545,7 +1545,7 @@ class TestRegression(TestCase):
s3 = asbytes('other')
a = np.array([[s1],[s2],[s3]])
assert_equal(a.dtype, np.dtype('S5'))
- b = a.astype('str')
+ b = a.astype(np.dtype('S0'))
assert_equal(b.dtype, np.dtype('S5'))
def test_ticket_1756(self):