diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2019-01-14 23:18:39 -0800 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2019-01-14 23:21:44 -0800 |
commit | aa8f67ea4a92007059d240241a54ec3b3c1aacc9 (patch) | |
tree | e140a53455909e2cef75ae3704a616f188e6cec7 | |
parent | 9d8ca1ddc0f8893f799f40bc6e25c57a42bbcb8a (diff) | |
download | numpy-aa8f67ea4a92007059d240241a54ec3b3c1aacc9.tar.gz |
BUG: Fix crash in error message formatting introduced by gh-11230
Fixes gh-11221, and now produces:
```python
>>> a = np.ones((3, 3, 4, 5, 6))
>>> b = np.ones((3, 4, 5))
>>> np.einsum('aabcb,abc', a, b)
ValueError: dimensions in operand 0 for collapsing index 'b' don't match (4 != 6)
```
-rw-r--r-- | numpy/core/src/multiarray/einsum.c.src | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/einsum.c.src b/numpy/core/src/multiarray/einsum.c.src index eb2b33870..e7bbc3d0b 100644 --- a/numpy/core/src/multiarray/einsum.c.src +++ b/numpy/core/src/multiarray/einsum.c.src @@ -2156,10 +2156,11 @@ get_combined_dims_view(PyArrayObject *op, int iop, char *labels) icombinemap[idim] = -1; if (new_dims[i] != dim) { + char orig_label = labels[idim + label]; PyErr_Format(PyExc_ValueError, "dimensions in operand %d for collapsing " "index '%c' don't match (%d != %d)", - iop, label, (int)new_dims[i], (int)dim); + iop, orig_label, (int)new_dims[i], (int)dim); return NULL; } new_strides[i] += stride; |