Author: Antonio Cuni <[email protected]>
Branch: ndarray-buffer
Changeset: r68244:8593deb29c94
Date: 2013-11-19 16:32 +0100
http://bitbucket.org/pypy/pypy/changeset/8593deb29c94/
Log: test and fix
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
@@ -1093,6 +1093,7 @@
storage = rffi.cast(RAW_STORAGE_PTR, raw_ptr)
storage = rffi.ptradd(storage, offset)
return W_NDimArray.from_shape_and_storage(space, shape, storage, dtype,
+ w_subtype=w_subtype,
w_base=w_buffer)
if not 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
@@ -2098,6 +2098,15 @@
assert list(buf) == ['b', '\x00', 'a', '\x00', 'r', '\x00']
assert a.base is buf
+ def test_ndarray_subclass_from_buffer(self):
+ import numpypy as np
+ import array
+ buf = array.array('c', ['\x00']*2*3)
+ class X(np.ndarray):
+ pass
+ a = X((3,), buffer=buf, dtype='i2')
+ assert type(a) is X
+
def test_ndarray_from_buffer_and_offset(self):
import numpypy as np
import array
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit