[pypy-commit] pypy default: test, fix for array(..., dtype=xxx, subok=True)

mattip noreply at buildbot.pypy.org
Sat Feb 14 19:28:50 CET 2015


Author: mattip <matti.picus at gmail.com>
Branch: 
Changeset: r75871:c745a42c6abe
Date: 2015-02-14 20:28 +0200
http://bitbucket.org/pypy/pypy/changeset/c745a42c6abe/

Log:	test, fix for array(..., dtype=xxx, subok=True)

diff --git a/pypy/module/micronumpy/ctors.py b/pypy/module/micronumpy/ctors.py
--- a/pypy/module/micronumpy/ctors.py
+++ b/pypy/module/micronumpy/ctors.py
@@ -81,7 +81,7 @@
                 return w_object.descr_copy(space, w_order)
             elif not copy and (subok or type(w_object) is W_NDimArray):
                 return w_object
-        if subok:
+        if subok and not type(w_object) is W_NDimArray:
             raise oefmt(space.w_NotImplementedError, 
                 "array(..., subok=True) only partially implemented")
         # we have a ndarray, but need to copy or change dtype 
diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py
--- a/pypy/module/micronumpy/test/test_subtype.py
+++ b/pypy/module/micronumpy/test/test_subtype.py
@@ -26,6 +26,12 @@
                     self.called_finalize = True
             return SubType ''')
 
+    def test_subtype_ndarray(self):
+        from numpy import arange, array
+        a = arange(24, dtype='int32').reshape((6,4))
+        b = array(a, dtype='float64', subok=True)
+        assert (a == b).all()
+
     def test_subtype_base(self):
         from numpy import ndarray, dtype
         class C(ndarray):


More information about the pypy-commit mailing list