[pypy-commit] pypy numpypy-out: force non-lazy behaviour for ufuncs
mattip
noreply at buildbot.pypy.org
Wed Feb 15 23:56:54 CET 2012
Author: mattip
Branch: numpypy-out
Changeset: r52532:481d17327eeb
Date: 2012-02-16 00:56 +0200
http://bitbucket.org/pypy/pypy/changeset/481d17327eeb/
Log: force non-lazy behaviour for ufuncs
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
@@ -783,6 +783,7 @@
self.values = None
def create_sig(self):
+ print 'Call1::create_sig'
if self.forced_result is not None:
return self.forced_result.create_sig()
return signature.Call1(self.ufunc, self.name, self.calc_dtype,
@@ -943,7 +944,7 @@
def setitem(self, item, value):
self.invalidated()
- self.dtype.setitem(self.storage, item, value)
+ self.dtype.setitem(self.storage, item, value.convert_to(self.dtype))
def calc_strides(self, shape):
strides = []
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
@@ -262,6 +262,9 @@
w_res = Call1(self.func, self.name, w_obj.shape, calc_dtype, res_dtype,
w_obj, out)
w_obj.add_invalidates(w_res)
+ if out:
+ #Force it immediately
+ w_res.get_concrete()
return w_res
diff --git a/pypy/module/micronumpy/test/test_outarg.py b/pypy/module/micronumpy/test/test_outarg.py
--- a/pypy/module/micronumpy/test/test_outarg.py
+++ b/pypy/module/micronumpy/test/test_outarg.py
@@ -36,9 +36,9 @@
a = array([[1, 2], [3, 4]])
c = zeros((2,2,2))
b = negative(a + a, out=c[1])
- print c
+ #test for view, and also test that forcing out also forces b
+ assert (c[:, :, 1] == [[0, 0], [-4, -8]]).all()
assert (b == [[-2, -4], [-6, -8]]).all()
- assert (c[:, :, 1] == [[0, 0], [-4, -8]]).all()
def test_ufunc_cast(self):
from _numpypy import array, negative
More information about the pypy-commit
mailing list