Author: Matti Picus <[email protected]>
Branch: ndarray-subtype
Changeset: r65186:9c65421e84ec
Date: 2013-07-04 23:52 +0300
http://bitbucket.org/pypy/pypy/changeset/9c65421e84ec/
Log: fix for existing tests
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
@@ -41,10 +41,16 @@
impl = concrete.ConcreteArray(shape, dtype.base, order, strides,
backstrides)
if subtype:
- ret = space.allocate_instance(W_NDimArray, space.type(subtype))
+ if space.isinstance_w(subtype, space.w_type):
+ #got type, probably from descr_XXX
+ ret = space.allocate_instance(W_NDimArray, subtype)
+ else:
+ #got instance
+ ret = space.allocate_instance(W_NDimArray, space.type(subtype))
W_NDimArray.__init__(ret, impl)
- return ret
- return W_NDimArray(impl)
+ else:
+ ret = W_NDimArray(impl)
+ return ret
@staticmethod
def from_shape_and_storage(space, shape, storage, dtype, order='C',
owning=False, subtype=None):
@@ -59,7 +65,12 @@
impl = concrete.ConcreteArrayNotOwning(shape, dtype, order,
strides,
backstrides, storage)
if subtype:
- ret = space.allocate_instance(W_NDimArray, space.type(subtype))
+ if space.isinstance_w(subtype, space.w_type):
+ #got type, probably from descr_XXX
+ ret = space.allocate_instance(W_NDimArray, subtype)
+ else:
+ #got instance
+ ret = space.allocate_instance(W_NDimArray, space.type(subtype))
W_NDimArray.__init__(ret, impl)
return ret
return W_NDimArray(impl)
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
@@ -627,9 +627,13 @@
"trace not implemented yet"))
def descr_view(self, space, w_dtype=None, w_type=None) :
- if not w_type and w_dtype and
w_dtype.issubtype(space.gettypefor(W_NDimArray)):
- w_type = w_dtype
- w_dtype = None
+ if not w_type and w_dtype:
+ try:
+ if w_dtype.issubtype(space.gettypefor(W_NDimArray)):
+ w_type = w_dtype
+ w_dtype = None
+ except:
+ pass
if w_dtype:
dtype = space.interp_w(interp_dtype.W_Dtype,
space.call_function(space.gettypefor(interp_dtype.W_Dtype),
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit