<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div><div>On Jun 7, 2012, at 4:32 AM, Paul Anton Letnes wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On 7. juni 2012, at 10:30, Thouis (Ray) Jones wrote:<br><br><blockquote type="cite">I've opened a PR at <a href="https://github.com/numpy/numpy/pull/296">https://github.com/numpy/numpy/pull/296</a> for discussion.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">A typical result<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">np.zeros((3,3))[[1,2,3]]<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite">Traceback (most recent call last):<br></blockquote><blockquote type="cite"> File "<stdin>", line 1, in <module><br></blockquote><blockquote type="cite">IndexError: index 3 is out of bounds for axis 0: [-3,3)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Ray Jones<br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">NumPy-Discussion mailing list<br></blockquote><blockquote type="cite"><a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br></blockquote><blockquote type="cite"><a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br></blockquote><br><br>I would prefer:<br>IndexError: index 3 is out of bounds for axis 0: [-3,2]<br>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.<br></div></blockquote><div><br></div><div><div><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">Actually, with slicing, you can attempt indexing using floats (as referred to here: <a href="http://stackoverflow.com/questions/8514547/why-ndarray-allow-floating-point-index">http://stackoverflow.com/questions/8514547/why-ndarray-allow-floating-point-index</a>), so I disagree with the integer notation [-3,2]</span></div><div><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><br></span></div><div><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">I actually prefer the subsequent suggestion of reporting the shape, since that's what I always check when debugging index errors anyway -- having it in the error message would save me a ton of time.</span></div><div><br></div></div><br><blockquote type="cite"><div><br>An alternative is to not refer to negative indices and say<br>IndexError: index 3 is out of bounds for axis 0, shape was: (3,)<br>(print more axes when the number of axes is higher.)<br><br>BTW, I'm really glad someone is taking an interest in these error messages, it's a great idea!<br><br></div></blockquote><div><br></div><div>… an enthusiastic +1!</div><br><blockquote type="cite"><div>Paul<br><br></div></blockquote></div><br></body></html>