[Numpy-discussion] better error message possible?
Tue Jun 5 07:41:09 CDT 2012
On Tue, Jun 5, 2012 at 12:15 PM, Thouis Jones <email@example.com> wrote:
> On Mon, Jun 4, 2012 at 11:49 PM, Nathaniel Smith <firstname.lastname@example.org> wrote:
>> On Mon, Jun 4, 2012 at 10:00 PM, Thouis (Ray) Jones <email@example.com> wrote:
>>> On Mon, Jun 4, 2012 at 4:27 PM, Thouis (Ray) Jones <firstname.lastname@example.org> 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:
>> Fabulous! I made a few comments there, but also:
>>> A typical result:
>>> 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