[pypy-commit] pypy ufuncapi: correct the test so it now fails
mattip
noreply at buildbot.pypy.org
Tue Nov 18 23:45:19 CET 2014
Author: mattip <matti.picus at gmail.com>
Branch: ufuncapi
Changeset: r74574:8932643e5a01
Date: 2014-11-18 21:52 +0200
http://bitbucket.org/pypy/pypy/changeset/8932643e5a01/
Log: correct the test so it now fails
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -162,10 +162,9 @@
def test_frompyfunc_2d_sig(self):
def times_2(in_array, out_array):
- in_flat = in_array.flat
- out_flat = out_array.flat
- for i in range(in_array.size):
- out_flat[i] = in_flat[i] * 2
+ assert len(in_array.shape) == 2
+ assert in_array.shape == out_array.shape
+ out_array[:] = in_array * 2
from numpy import frompyfunc, dtype, arange
ufunc = frompyfunc([times_2], 1, 1,
signature='(m,m)->(m,m)',
@@ -176,7 +175,7 @@
exc = raises(ValueError, ufunc, ai[:,:,0])
assert "mismatch in its core dimension 1" in exc.value.message
ai2 = ufunc(ai)
- assert all(ai1 == ai * 2)
+ assert (ai2 == ai * 2).all()
def test_ufunc_kwargs(self):
from numpy import ufunc, frompyfunc, arange, dtype
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -699,7 +699,8 @@
# TODO parse and handle subok
# TODO handle flags, op_flags
w_flags = space.w_None #space.newlist([space.wrap('external_loop')])
- w_op_flags = space.w_None
+ w_op_flags = space.newtuple([space.wrap(['readonly'])] * len(inargs) + \
+ [space.wrap(['readwrite'])] * len(outargs))
w_op_dtypes = space.w_None
w_casting = space.w_None
w_itershape = space.newlist([space.wrap(i) for i in iter_shape])
@@ -708,7 +709,6 @@
# mimic NpyIter_AdvancedNew with a nditer
if self.stack_inputs:
- inargs = inargs + outargs
nd_it = W_NDIter(space, space.newlist(inargs + outargs), w_flags,
w_op_flags, w_op_dtypes, w_casting, w_op_axes,
w_itershape)
More information about the pypy-commit
mailing list