Author: Matti Picus <[email protected]>
Branch: ndarray-view
Changeset: r65060:c4938bea5968
Date: 2013-06-28 14:26 +0300
http://bitbucket.org/pypy/pypy/changeset/c4938bea5968/
Log: ndarray passes
diff --git a/pypy/module/micronumpy/interp_numarray.py
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -635,12 +635,12 @@
new_shape = self.get_shape()
impl = self.implementation
if impl.get_strides()[0] < impl.get_strides()[-1]:
- new_shape[0] = int(new_shape[0] * factor)
+ new_shape[0] = int(new_shape[0] / factor)
if new_shape[0] == 0:
raise OperationError(space.w_ValueError, space.wrap(
"new type not compatible with array shape"))
else:
- new_shape[-1] = int(new_shape[-1] * factor)
+ new_shape[-1] = int(new_shape[-1] / factor)
if new_shape[-1] == 0:
raise OperationError(space.w_ValueError, space.wrap(
"new type not compatible with array shape"))
diff --git a/pypy/module/micronumpy/test/test_numarray.py
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1412,7 +1412,7 @@
assert a[2].imag == -5
def test_ndarray_view(self):
- from numpypy import array, int8, int16, dtype, int64
+ from numpypy import array, int8, int16, dtype
x = array([(1, 2)], dtype=[('a', int8), ('b', int8)])
y = x.view(dtype=int16)
print y,y.shape
@@ -1421,20 +1421,23 @@
y[0] = 670
assert x['a'] == -98
assert x['b'] == 2
- f = array([1000, -1234], dtype='i')
+ f = array([1000, -1234], dtype='i4')
nnp = self.non_native_prefix
- d = f.view(dtype=nnp + 'i')
+ d = f.view(dtype=nnp + 'i4')
assert (d == [-402456576, 788267007]).all()
+ x = array(range(15), dtype='i2').reshape(3,5)
+ exc = raises(ValueError, x.view, dtype='i4')
+ assert exc.value[0] == "new type not compatible with array."
+ assert x.view('int8').shape == (3, 10)
+ x = array(range(15), dtype='int16').reshape(3,5).T
+ assert x.view('int8').shape == (10, 3)
+
+ def test_scalar_view(self):
+ from numpypy import int64
s = int64(12)
exc = raises(TypeError, s.view, dtype='int8')
assert exc.value[0] == "view() takes no keyword arguments"
assert s.view('double') < 7e-323
- x = array(range(15), dtype='int16').reshape(3,5)
- exc = raises(ValueError, x.view, dtype='int32')
- assert exc.value[0] == "new type not compatible with array."
- assert x.view('int8').shape == (3, 10)
- x = array(range(15), dtype='int16').reshape(3,5).T
- assert x.view('int8').shape == (10, 3)
def test_tolist_scalar(self):
from numpypy import int32, bool_
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit