[Numpy-discussion] better error message possible?
Paul Anton Letnes
Thu Jun 7 04:32:53 CDT 2012
On 7. juni 2012, at 10:30, Thouis (Ray) Jones wrote:
> I've opened a PR at https://github.com/numpy/numpy/pull/296 for discussion.
> A typical result
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> IndexError: index 3 is out of bounds for axis 0: [-3,3)
> Ray Jones
> NumPy-Discussion mailing list
I would prefer:
IndexError: index 3 is out of bounds for axis 0: [-3,2]
as I find the 3) notation a bit weird - after all, indices are not floats, so 2.999 or 2.3 doesn't make sense as an index.
An alternative is to not refer to negative indices and say
IndexError: index 3 is out of bounds for axis 0, shape was: (3,)
(print more axes when the number of axes is higher.)
BTW, I'm really glad someone is taking an interest in these error messages, it's a great idea!
More information about the NumPy-Discussion