<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 31 Aug 2016, at 15:22, Robert Kern <<a href="mailto:robert.kern@gmail.com" class="">robert.kern@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Wed, Aug 31, 2016 at 12:28 PM, Matti Viljamaa <<a href="mailto:mviljamaa@kapsi.fi" class="">mviljamaa@kapsi.fi</a>> wrote:<br class="">><br class="">> Is there a clean way to include the last element when subindexing numpy arrays?<br class="">> Since the default behaviour of numpy arrays is to omit the “stop index”.<br class="">><br class="">> So for,<br class="">><br class="">> >>> A<br class="">> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])<br class="">> >>> A[0:5]<br class="">> array([0, 1, 2, 3, 4])<br class=""><br class="">A[5:]<br class=""><br class="">--<br class="">Robert Kern</div></div></blockquote><div><br class=""></div><div>No that returns the subarray starting from index 5 to the end.</div><div><br class=""></div><div>What I want to be able to return</div><div><br class=""></div><div>array([0, 1, 2, 3, 4, 5])</div><div><br class=""></div><div>(i.e. last element 5 included)</div><div><br class=""></div><div>but without the funky A[0:6] syntax, which looks like it should return</div><div><br class=""></div><div><div>array([0, 1, 2, 3, 4, 5, 6])</div><div><br class=""></div><div>but since bumpy arrays omit the last index, returns</div><div><br class=""></div><div><div>array([0, 1, 2, 3, 4, 5])</div><div><br class=""></div><div>which syntactically would be more reasonable to be A[0:5].</div></div></div><br class=""><blockquote type="cite" class=""><div class="">
_______________________________________________<br class="">NumPy-Discussion mailing list<br class=""><a href="mailto:NumPy-Discussion@scipy.org" class="">NumPy-Discussion@scipy.org</a><br class="">https://mail.scipy.org/mailman/listinfo/numpy-discussion<br class=""></div></blockquote></div><br class=""></body></html>