[pypy-commit] pypy default: allow from_shape to create scalar arrays

mattip noreply at buildbot.pypy.org
Thu Feb 7 22:32:23 CET 2013


Author: mattip <matti.picus at gmail.com>
Branch: 
Changeset: r60943:f8b66eb99972
Date: 2013-02-07 18:48 +0200
http://bitbucket.org/pypy/pypy/changeset/f8b66eb99972/

Log:	allow from_shape to create scalar arrays

diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py
--- a/pypy/module/micronumpy/base.py
+++ b/pypy/module/micronumpy/base.py
@@ -21,11 +21,13 @@
     
     @staticmethod
     def from_shape(shape, dtype, order='C'):
-        from pypy.module.micronumpy.arrayimpl import concrete
-
-        assert shape
-        strides, backstrides = calc_strides(shape, dtype, order)
-        impl = concrete.ConcreteArray(shape, dtype, order, strides,
+        from pypy.module.micronumpy.arrayimpl import concrete, scalar
+        
+        if not shape:
+            impl = scalar.Scalar(dtype)
+        else:
+            strides, backstrides = calc_strides(shape, dtype, order)
+            impl = concrete.ConcreteArray(shape, dtype, order, strides,
                                       backstrides)
         return W_NDimArray(impl)
 


More information about the pypy-commit mailing list