Author: mattip <[email protected]>
Branch: numpy-1.10
Changeset: r80601:e1c02aa1e188
Date: 2015-11-09 01:02 +0200
http://bitbucket.org/pypy/pypy/changeset/e1c02aa1e188/
Log: fix tests for -A with numpy 1.10
diff --git a/pypy/module/micronumpy/test/test_dtypes.py
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -349,9 +349,8 @@
pass
assert np.dtype(xyz).name == 'xyz'
# another obscure API, used in numpy record.py
- # it seems numpy throws away the subclass type and parses the spec
a = np.dtype((xyz, [('x', 'int32'), ('y', 'float32')]))
- assert repr(a) == "dtype([('x', '<i4'), ('y', '<f4')])"
+ assert repr(a).endswith("xyz, [('x', '<i4'), ('y', '<f4')]))")
def test_index(self):
import numpy as np
@@ -486,12 +485,7 @@
class O(object):
pass
for o in [object, O]:
- if self.ptr_size == 4:
- assert np.dtype(o).str == '|O4'
- elif self.ptr_size == 8:
- assert np.dtype(o).str == '|O8'
- else:
- assert False,'self._ptr_size unknown'
+ assert np.dtype(o).str == '|O'
# Issue gh-2798
if '__pypy__' in sys.builtin_module_names:
a = np.array(['a'], dtype="O")
@@ -499,7 +493,7 @@
skip("(base_dtype, new_dtype) dtype specification discouraged")
a = np.array(['a'], dtype="O").astype(("O", [("name", "O")]))
assert a[0] == 'a'
- assert a == 'a'
+ assert a != 'a'
assert a['name'].dtype == a.dtype
class AppTestTypes(BaseAppTestDtypes):
@@ -1038,13 +1032,7 @@
assert d.name == "string64"
assert d.num == 18
for i in [1, 2, 3]:
- d = dtype('c%d' % i)
- assert d.itemsize == 1
- assert d.kind == 'S'
- assert d.type is str_
- assert d.name == 'string8'
- assert d.num == 18
- assert d.str == '|S1'
+ raises(TypeError, dtype, 'c%d' % i)
def test_unicode_dtype(self):
from numpy import dtype, unicode_
diff --git a/pypy/module/micronumpy/test/test_ndarray.py
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -269,7 +269,7 @@
assert (y == x.T).all()
exc = raises(ValueError, ndarray, [1,2,256]*10000)
- assert exc.value[0] == 'sequence too large; must be smaller than 32'
+ assert exc.value[0] == 'sequence too large; cannot be greater than 32'
exc = raises(ValueError, ndarray, [1,2,256]*10)
assert exc.value[0] == 'array is too big.'
@@ -844,8 +844,7 @@
from numpy import scalar
exc = raises(TypeError, scalar, int, 2)
assert exc.value[0] == 'argument 1 must be numpy.dtype, not type'
- exc = raises(ValueError, scalar, dtype('void'), 'abc')
- assert exc.value[0] == 'itemsize cannot be zero'
+ a = scalar(dtype('void'), 'abc')
exc = raises(TypeError, scalar, dtype(float), 2.5)
assert exc.value[0] == 'initializing object must be a string'
exc = raises(ValueError, scalar, dtype(float), 'abc')
@@ -1081,14 +1080,6 @@
for i in range(5):
assert a[i] == getattr(c[i], reg_op).__call__(d[i])
- def test_inplace_cast(self):
- import numpy as np
- a = np.zeros(5, dtype=np.float64)
- b = np.zeros(5, dtype=np.complex64)
- a += b
- assert a.sum() == 0
- assert a.dtype is np.dtype(np.float64)
-
def test_add_list(self):
from numpy import array, ndarray
a = array(range(5))
@@ -1965,7 +1956,7 @@
assert len(a) == 6
assert (a == [0,1,2,3,4,5]).all()
assert a.dtype is dtype(int)
- a = concatenate((a1, a2), axis=1)
+ a = concatenate((a1, a2), axis=0)
assert (a == [0,1,2,3,4,5]).all()
a = concatenate((a1, a2), axis=-1)
assert (a == [0,1,2,3,4,5]).all()
@@ -2013,7 +2004,7 @@
g1 = array([0,1,2])
g2 = array([[3,4,5]])
- exc = raises(ValueError, concatenate, (g1, g2), axis=2)
+ exc = raises(ValueError, concatenate, (g1, g2), axis=0)
assert str(exc.value) == \
"all the input arrays must have same number of dimensions"
@@ -2129,16 +2120,16 @@
assert exc.value.message == "'axis' entry 5 is out of bounds [-4, 4)"
exc = raises(ValueError, a.squeeze, 0)
assert exc.value.message == "cannot select an axis to squeeze out " \
- "which has size greater than one"
+ "which has size not equal to one"
exc = raises(ValueError, a.squeeze, (1, 1))
assert exc.value.message == "duplicate value in 'axis'"
def test_swapaxes(self):
from numpy import array
x = array([])
- assert x.swapaxes(0, 2) is x
+ raises(ValueError, x.swapaxes,0, 2)
x = array([[1, 2]])
- assert x.swapaxes(0, 0) is x
+ assert x.swapaxes(0, 0) is not x
exc = raises(ValueError, x.swapaxes, -3, 0)
assert exc.value.message == "bad axis1 argument to swapaxes"
exc = raises(ValueError, x.swapaxes, 0, 3)
@@ -2169,7 +2160,7 @@
# test virtual
assert ((x + x).swapaxes(0,1) == array([[[ 2, 4, 6], [14, 16, 18]],
[[ 8, 10, 12], [20, 22, 24]]])).all()
- assert array(1).swapaxes(10, 12) == 1
+ raises(ValueError, array(1).swapaxes, 10, 12)
def test_filter_bug(self):
from numpy import array
@@ -2415,7 +2406,8 @@
assert a[1] == 0xff
assert len(a.data) == 16
assert type(a.data) is buffer
- assert a[1:].data._pypy_raw_address() - a.data._pypy_raw_address() ==
a.strides[0]
+ if '__pypy__' in sys.builtin_module_names:
+ assert a[1:].data._pypy_raw_address() - a.data._pypy_raw_address()
== a.strides[0]
def test_explicit_dtype_conversion(self):
from numpy import array
@@ -2502,7 +2494,7 @@
def test_string_filling(self):
import numpy
- a = numpy.empty((10,10), dtype='c1')
+ a = numpy.empty((10,10), dtype='S1')
a.fill(12)
assert (a == '1').all()
@@ -3723,7 +3715,7 @@
assert a[()]['y'] == 0
assert a.shape == ()
a = zeros(2, dtype=[('x', int), ('y', float)])
- raises(IndexError, 'a[0]["xyz"]')
+ raises(ValueError, 'a[0]["xyz"]')
assert a[0]['x'] == 0
assert a[0]['y'] == 0
exc = raises(ValueError, "a[0] = (1, 2, 3)")
@@ -3791,7 +3783,7 @@
exc = raises(IndexError, "arr[3L]")
assert exc.value.message == "too many indices for array"
exc = raises(ValueError, "arr['xx'] = 2")
- assert exc.value.message == "field named xx not found"
+ assert exc.value.message == "no field of name xx"
assert arr['y'].dtype == a
assert arr['y'].shape == ()
assert arr['y'][()]['x'] == 0
@@ -3966,8 +3958,8 @@
exc = raises(IndexError, "a[0][%d]" % v)
assert exc.value.message == "invalid index (%d)" % \
(v + 2 if v < 0 else v)
- exc = raises(IndexError, "a[0]['z']")
- assert exc.value.message == "invalid index"
+ exc = raises(ValueError, "a[0]['z']")
+ assert exc.value.message == "no field of name z"
exc = raises(IndexError, "a[0][None]")
assert exc.value.message == "invalid index"
@@ -4150,7 +4142,7 @@
d = np.ones(3, dtype=[('a', 'i8'), ('b', 'i8')])
e = np.ones(3, dtype=[('a', 'i8'), ('b', 'i8'), ('c', 'i8')])
exc = raises(TypeError, abs, a)
- assert exc.value[0] == 'Not implemented for this type'
+ assert exc.value[0].startswith("ufunc 'absolute' did not contain a
loop")
assert (a == a).all()
assert not (a != a).any()
assert (a == b).all()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit