Commits

Antonio Cuni committed 8593deb

test and fix

Comments (0)

Files changed (2)

pypy/module/micronumpy/interp_numarray.py

         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:

pypy/module/micronumpy/test/test_numarray.py

         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