numpy/numpy — pull request #2701 by seberg (2012-10-30 19:53:40+00:00)
Title: Fancy Indexing enhancements and bug fixes

First of, I have not included this here, but I have a script for testing fancy indexing at https://gist.github.com/3982352 however it is very slow (~40 minutes :)), because I just try a huge amount of combinations for indexes, and not very clean. It doesn't test broadcasting with assignments, but other then that it has code to mimic fancy indexing, so maybe with smarter choice of testcases it could be added to the normal testsuit.

This PR includes fixes and enhancements for indexing:

1. Fix Issue #1769. This was due to how subspace selection worked. I propagated `check_index` through more functions to be able to suppress the unnecessary index checking for the subspace selection, since at that point all integer indices should be 0 as all none slices/Ellipsis/Nones were converted to index arrays.
2. Allow None/newaxis in combination with fancy-indexes. To achieve that I changed `mit->consec` to be the axes to which the fancy axes are transposed, which means it largely retains its meaning (though consecutive can be 0 if they are consecutive at the start now).
3. Fix a rare segfault because there was no check if the resulting array is too large.
4. The non-fancy indexes were ignored when the fancy indexes had the correct dimension. This does not make sense, subspace selection is now done but if its 0-d ignored. (this is more important after allowing newaxis, since its not only allowing bad indexes but giving wrong results for legal ones)

I know how to fix Issue Issue #579, but it should probably be special cased early and I am not sure how (I think the biggest oddity are likely zero-sized boolean indices now). Maybe some of these changes are not good, I can pull them out then.