Author: Matti Picus <matti.pi...@gmail.com> Branch: numpypy-array_prepare_-array_wrap Changeset: r67044:47a1da6a0385 Date: 2013-09-21 23:51 +0300 http://bitbucket.org/pypy/pypy/changeset/47a1da6a0385/
Log: implement for W_Ufunc1 diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -325,15 +325,17 @@ w_obj.get_scalar_value().convert_to(calc_dtype)) if out is None: return w_val - if out.is_scalar(): - out.set_scalar_value(w_val) - else: - out.fill(res_dtype.coerce(space, w_val)) - return out + if isinstance(out, W_NDimArray): + if out.is_scalar(): + out.set_scalar_value(w_val) + else: + out.fill(res_dtype.coerce(space, w_val)) + return self.call_prepare(space, out, w_obj, w_val) shape = shape_agreement(space, w_obj.get_shape(), out, broadcast_down=False) - return loop.call1(space, shape, self.func, calc_dtype, res_dtype, + w_result = loop.call1(space, shape, self.func, calc_dtype, res_dtype, w_obj, out) + return self.call_prepare(space, out, w_obj, w_result) class W_Ufunc2(W_Ufunc): @@ -408,6 +410,7 @@ else: out.fill(arr) arr = out + # XXX handle array_priority return self.call_prepare(space, out, w_lhs, arr) new_shape = shape_agreement(space, w_lhs.get_shape(), w_rhs) new_shape = shape_agreement(space, new_shape, out, broadcast_down=False) 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 @@ -299,8 +299,11 @@ return array(arr[0]).view(type=with_prepare) a = array(1) b = array(1).view(type=with_prepare) + print 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' x = log(a, out=b) + print 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' assert x == 0 + print 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' assert type(x) == with_prepare assert x.called_prepare x.called_prepare = False _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit