[Numpy-discussion] better error message possible?
Thouis Jones
thouis.jones@curie...
Tue Jun 5 07:41:09 CDT 2012
On Tue, Jun 5, 2012 at 12:15 PM, Thouis Jones <thouis.jones@curie.fr> wrote:
> On Mon, Jun 4, 2012 at 11:49 PM, Nathaniel Smith <njs@pobox.com> wrote:
>> On Mon, Jun 4, 2012 at 10:00 PM, Thouis (Ray) Jones <thouis@gmail.com> wrote:
>>> On Mon, Jun 4, 2012 at 4:27 PM, Thouis (Ray) Jones <thouis@gmail.com> wrote:
>>>> I could look into this. There are only ~10 places the code generates
>>>> this error, so it should be a pretty minor change.
>>>
>>> My initial estimate was low, but not overly so. An initial pass at
>>> adding index/dimension information to IndexErrors is here:
>>> https://github.com/thouis/numpy/tree/index_error_info
>>
>> Fabulous! I made a few comments there, but also:
>>
>>> A typical result:
>>>
>>>>>> numpy.zeros(3)[5]
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> IndexError: index 5 out of bounds in dimension 0
>>
>> I would say "for", not "in".
>>
>> "index 5" is a bit ambiguous too... people might mis-read it as the
>> dimension, like, "the 5th index value I gave"? Not sure how to make it
>> unambiguous. Maybe:
>>
>> "IndexError: dimension 0 index out of bounds: got 5, size is 3"
>>
>> ?
>
> How about:
> IndexError: 5 is out of bounds for dimension 0: must be in [-3, 3).
>
> to be maximally explicit about what values are allowed, and avoid the
> "index" confusion.
Or perhaps "axis" instead of "dimension", since this is how they are
referred to in most numpy argument lists.
More information about the NumPy-Discussion
mailing list