<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Feb 2, 2014 at 10:06 AM, Charles R Harris <span dir="ltr"><<a href="mailto:charlesr.harris@gmail.com" target="_blank">charlesr.harris@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Sebastian has done a lot of work to refactor/rationalize numpy indexing. The changes are extensive enough that it would be good to have more public review, so here is the release note.<br>
<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
The NumPy indexing has seen a complete rewrite in this version. This makes<br>most advanced integer indexing operations much faster and should have no<br>other implications.<br>However some subtle changes and deprecations were introduced in advanced<br>
indexing operations:<br><br> * Boolean indexing into scalar arrays will always return a new 1-d array.<br> This means that ``array(1)[array(True)]`` gives ``array([1])`` and<br> not the original array.<br> * Advanced indexing into one dimensional arrays used to have (undocumented)<br>
special handling regarding repeating the value array in assignments<br> when the shape of the value array was too small or did not match.<br> Code using this will raise an error. For compatibility you can use<br>
``arr.flat[index] = values``, which uses the old code branch.<br> * The iteration order over advanced indexes used to be always C-order.<br> In NumPy 1.9. the iteration order adapts to the inputs and is not<br> guaranteed (with the exception of a *single* advanced index which is<br>
never reversed for compatibility reasons). This means that the result is<br> undefined if multiple values are assigned to the same element.<br> An example for this is ``arr[[0, 0], [1, 1]] = [1, 2]``, which may<br>
set ``arr[0, 1]`` to either 1 or 2.<br> * Equivalent to the iteration order, the memory layout of the advanced<br> indexing result is adapted for faster indexing and cannot be predicted.<br> * All indexing operations return a view or a copy. No indexing operation<br>
will return the original array object.<br> * In the future Boolean array-likes (such as lists of python bools)<br> will always be treated as Boolean indexes and Boolean scalars (including<br> python `True`) will be a legal *boolean* index. At this time, this is<br>
already the case for scalar arrays to allow the general<br> ``positive = a[a > 0]`` to work when ``a`` is zero dimensional.<br> * In NumPy 1.8 it was possible to use `array(True)` and `array(False)`<br> equivalent to 1 and 0 if the result of the operation was a scalar.<br>
This will raise an error in NumPy 1.9 and, as noted above, treated as a<br> boolean index in the future.<br> * All non-integer array-likes are deprecated, object arrays of custom<br> integer like objects may have to be cast explicitly.<br>
* The error reporting for advanced indexing is more informative, however<br> the error type has changed in some cases. (Broadcasting errors of<br> indexing arrays are reported as `IndexError`)<br> * Indexing with more then one ellipsis (`...`) is deprecated.<br>
</blockquote><br></div>Thoughts?<br><br></div></div></blockquote><div><br></div><div>The PR is <a href="https://github.com/numpy/numpy/pull/3798">#3798</a> if you want to test it.<br><br></div><div>Chuck </div></div><br>
</div></div>