Author: Alex Gaynor <[email protected]>
Branch: numpy-dtype-alt
Changeset: r46774:7a90f6c151a4
Date: 2011-08-25 17:34 -0400
http://bitbucket.org/pypy/pypy/changeset/7a90f6c151a4/
Log: fix for array.dot() with a sequence (but non-array) argument.
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
@@ -200,12 +200,13 @@
descr_argmin = _reduce_argmax_argmin_impl("min")
def descr_dot(self, space, w_other):
- if isinstance(w_other, BaseArray):
+ w_other = convert_to_array(space, w_other)
+ if isinstance(w_other, Scalar):
+ return self.descr_mul(space, w_other)
+ else:
w_res = self.descr_mul(space, w_other)
assert isinstance(w_res, BaseArray)
return w_res.descr_sum(space)
- else:
- return self.descr_mul(space, w_other)
def _getnums(self, comma):
dtype = self.find_dtype()
diff --git a/pypy/module/micronumpy/test/test_numarray.py
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -490,6 +490,9 @@
a = array(range(5))
assert a.dot(a) == 30.0
+ a = array(range(5))
+ assert a.dot(range(5)) == 30
+
def test_dot_constant(self):
from numpy import array
a = array(range(5))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit