NOTE: If ``obj`` is a dask array it is implicitly computed when this function is called.
(arr, obj, axis)
| 2458 | |
| 2459 | @derived_from(np) |
| 2460 | def delete(arr, obj, axis): |
| 2461 | """ |
| 2462 | NOTE: If ``obj`` is a dask array it is implicitly computed when this function |
| 2463 | is called. |
| 2464 | """ |
| 2465 | # axis is a required argument here to avoid needing to deal with the numpy |
| 2466 | # default case (which reshapes the array to make it flat) |
| 2467 | axis = validate_axis(axis, arr.ndim) |
| 2468 | |
| 2469 | if isinstance(obj, slice): |
| 2470 | tmp = np.arange(*obj.indices(arr.shape[axis])) |
| 2471 | obj = tmp[::-1] if obj.step and obj.step < 0 else tmp |
| 2472 | else: |
| 2473 | obj = np.asarray(obj) |
| 2474 | obj = np.where(obj < 0, obj + arr.shape[axis], obj) |
| 2475 | obj = np.unique(obj) |
| 2476 | |
| 2477 | target_arr = split_at_breaks(arr, obj, axis) |
| 2478 | |
| 2479 | target_arr = [ |
| 2480 | ( |
| 2481 | arr[ |
| 2482 | tuple( |
| 2483 | slice(1, None) if axis == n else slice(None) |
| 2484 | for n in range(arr.ndim) |
| 2485 | ) |
| 2486 | ] |
| 2487 | if i != 0 |
| 2488 | else arr |
| 2489 | ) |
| 2490 | for i, arr in enumerate(target_arr) |
| 2491 | ] |
| 2492 | return concatenate(target_arr, axis=axis) |
| 2493 | |
| 2494 | |
| 2495 | @derived_from(np) |
nothing calls this directly
no test coverage detected