Author: mattip <[email protected]>
Branch: ufunc-casting
Changeset: r80177:498bdeec8923
Date: 2015-10-13 23:48 +0300
http://bitbucket.org/pypy/pypy/changeset/498bdeec8923/
Log: test, fix divide-by-zero
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
@@ -198,6 +198,10 @@
ai2 = ufunc(aiV)
assert (ai2 == aiV * 2).all()
+ ai = arange(0).reshape(0, 1, 1)
+ ao = ufunc(ai)
+ assert ao.shape == (0, 1, 1)
+
def test_frompyfunc_needs_nditer(self):
import sys
from numpy import frompyfunc, dtype, arange
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
@@ -1119,7 +1119,7 @@
for j in range(offset, len(iter_shape)):
x = iter_shape[j + offset]
y = dims_to_broadcast[j]
- if (x > y and x % y) or y %x:
+ if y != 0 and x != 0 and ((x > y and x % y) or y %x):
raise oefmt(space.w_ValueError, "%s: %s operand %d has a "
"mismatch in its broadcast dimension %d "
"(size %d is different from %d)",
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit