Author: mattip <[email protected]>
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)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit