slice_with_newaxis : handle None/newaxis case slice_wrap_lists : handle fancy indexing with lists slice_slices_and_integers : handle everything else
(x, index)
| 223 | |
| 224 | |
| 225 | def slice_array(x, index): |
| 226 | """ |
| 227 | slice_with_newaxis : handle None/newaxis case |
| 228 | slice_wrap_lists : handle fancy indexing with lists |
| 229 | slice_slices_and_integers : handle everything else |
| 230 | """ |
| 231 | if all( |
| 232 | isinstance(index, slice) and index == slice(None, None, None) for index in index |
| 233 | ): |
| 234 | # all none slices |
| 235 | return x.expr |
| 236 | |
| 237 | # Add in missing colons at the end as needed. x[5] -> x[5, :, :] |
| 238 | not_none_count = sum(i is not None for i in index) |
| 239 | missing = len(x.chunks) - not_none_count |
| 240 | index += (slice(None, None, None),) * missing |
| 241 | return slice_with_newaxes(x, index) |
| 242 | |
| 243 | |
| 244 | def slice_with_newaxes(x, index): |
searching dependent graphs…