diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2011-05-18 09:40:32 -0500 |
---|---|---|
committer | Mark Wiebe <mwwiebe@gmail.com> | 2011-05-18 09:40:32 -0500 |
commit | 651a9421b6b869ef07d37336ddef791e96182bb5 (patch) | |
tree | a4eef32f761f97460e28feb7a1b317dda7808438 | |
parent | 9fb892241a0e7d23ab317e41fd77882e4a254c1f (diff) | |
download | numpy-651a9421b6b869ef07d37336ddef791e96182bb5.tar.gz |
BUG: PyArray_FillWithZero didn't work in the general case
The call to the stransfer function had incorrect arguments. This
didn't show up because all the tests of einsum, the only current
user of the function, produced contiguous arrays which are special
cased.
-rw-r--r-- | numpy/core/src/multiarray/convert.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_einsum.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/convert.c b/numpy/core/src/multiarray/convert.c index 5d40fc466..ffeb96ba9 100644 --- a/numpy/core/src/multiarray/convert.c +++ b/numpy/core/src/multiarray/convert.c @@ -447,7 +447,7 @@ PyArray_FillWithZero(PyArrayObject *a) } do { - stransfer(NULL, 0, *dataptr, stride, + stransfer(*dataptr, stride, NULL, 0, *countptr, 0, transferdata); } while(iternext(iter)); diff --git a/numpy/core/tests/test_einsum.py b/numpy/core/tests/test_einsum.py index 7f29889c2..4373db154 100644 --- a/numpy/core/tests/test_einsum.py +++ b/numpy/core/tests/test_einsum.py @@ -466,5 +466,13 @@ class TestEinSum(TestCase): def test_einsum_sums_clongdouble(self): self.check_einsum_sums(np.clongdouble); + def test_einsum_misc(self): + # This call used to crash because of a bug in + # PyArray_FillWithZero + a = np.ones((1,2)) + b = np.ones((2,2,1)) + assert_equal(np.einsum('ij...,j...->i...',a,b), [[[2],[2]]]) + + if __name__ == "__main__": run_module_suite() |