MCPcopy Create free account
hub / github.com/dask/dask / delete

Function delete

dask/array/routines.py:2460–2492  ·  view source on GitHub ↗

NOTE: If ``obj`` is a dask array it is implicitly computed when this function is called.

(arr, obj, axis)

Source from the content-addressed store, hash-verified

2458
2459@derived_from(np)
2460def 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)

Callers

nothing calls this directly

Calls 6

validate_axisFunction · 0.90
concatenateFunction · 0.90
split_at_breaksFunction · 0.85
arangeMethod · 0.45
whereMethod · 0.45
uniqueMethod · 0.45

Tested by

no test coverage detected