|
| 1 | +Improve `flatiter` indexing by using ndarray index preparation |
| 2 | +-------------------------------------------------------------- |
| 3 | + |
| 4 | +The `flatiter`` object now shares the same index preparation logic as |
| 5 | +`ndarray`, ensuring consistent behavior and fixing several issues where |
| 6 | +invalid indices were previously accepted or misinterpreted. |
| 7 | + |
| 8 | +Key fixes and improvements: |
| 9 | + |
| 10 | +* Stricter index validation |
| 11 | + |
| 12 | + ``arr.flat[[True, True]]`` and ``arr.flat[[1.0, 1.0]]`` were incorrectly |
| 13 | + treated as ``arr.flat[[1, 1]]``. They now raise an `IndexError`` (unless |
| 14 | + ``arr.flat[[True, Truee]]`` is a valid boolean index) |
| 15 | + |
| 16 | +* Fixed crash when assigning to an empty index tuple: |
| 17 | + |
| 18 | + ``arr.flat[()] = 0`` previously crashed the Python interpreter. It now |
| 19 | + correctly assigns to the entire array. |
| 20 | + |
| 21 | +* Consistent error types: |
| 22 | + |
| 23 | + Certain invalid `flatiter` indices that previously raised `ValueError` |
| 24 | + now correctly raise `IndexError`, aligning with `ndarray` behavior. |
| 25 | + |
| 26 | +* Improved error messages: |
| 27 | + |
| 28 | + The error message for unsupported index operations now provides more |
| 29 | + specific details, including explicitly listing the valid index types, |
| 30 | + instead of the generic ``IndexError: unsupported index operation``. |