Handle indexing with Nones Strips out Nones then hands off to slice_wrap_lists
(x, index)
| 242 | |
| 243 | |
| 244 | def slice_with_newaxes(x, index): |
| 245 | """ |
| 246 | Handle indexing with Nones |
| 247 | |
| 248 | Strips out Nones then hands off to slice_wrap_lists |
| 249 | """ |
| 250 | # Strip Nones from index |
| 251 | index2 = tuple(ind for ind in index if ind is not None) |
| 252 | where_none = [i for i, ind in enumerate(index) if ind is None] |
| 253 | for i, xx in enumerate(where_none): |
| 254 | n = sum(isinstance(ind, Integral) for ind in index[:xx]) |
| 255 | if n: |
| 256 | where_none[i] -= n |
| 257 | |
| 258 | # Pass down and do work |
| 259 | x = slice_wrap_lists(x, index2, not where_none) |
| 260 | |
| 261 | if where_none: |
| 262 | return SlicesWrapNone( |
| 263 | x.array, x.index, x.allow_getitem_optimization, where_none |
| 264 | ) |
| 265 | |
| 266 | else: |
| 267 | return x |
| 268 | |
| 269 | |
| 270 | def slice_wrap_lists(x, index, allow_getitem_optimization): |
no test coverage detected