[pypy-commit] pypy numpypy-argminmax: fix nasty bug: arg{min, max} of scalar
mattip
noreply at buildbot.pypy.org
Wed Jun 13 23:44:31 CEST 2012
Author: mattip <matti.picus at gmail.com>
Branch: numpypy-argminmax
Changeset: r55655:f03816dc879b
Date: 2012-06-14 00:44 +0300
http://bitbucket.org/pypy/pypy/changeset/f03816dc879b/
Log: fix nasty bug: arg{min,max} of scalar
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
@@ -187,7 +187,11 @@
get_printable_location=signature.new_printable_location(op_name),
name='numpy_' + op_name,
)
- def loop(self, axis, out):
+ def loop(self, space, axis, out):
+ if isinstance(self, Scalar):
+ return 0
+ if axis >= len(self.shape):
+ raise OperationError(space.w_ValueError, space.wrap("axis(=%d) out of bounds" % axis))
sig = self.find_sig()
frame = sig.create_frame(self)
cur_best = sig.eval(frame, self)
@@ -226,7 +230,7 @@
'output must be an array'))
else:
out = w_out
- return space.wrap(loop(self, axis, out))
+ return space.wrap(loop(self, space, axis, out))
return func_with_new_name(impl, "reduce_arg%s_impl" % op_name)
descr_argmax = _reduce_argmax_argmin_impl("max")
More information about the pypy-commit
mailing list