def delete(arr, obj, axis=None):
wrap = None<EOL>if type(arr) is not ndarray:<EOL><INDENT>try:<EOL><INDENT>wrap = arr.__array_wrap__<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>arr = asarray(arr)<EOL>ndim = arr.ndim<EOL>if axis is None:<EOL><INDENT>if ndim != <NUM_LIT:1>:<EOL><INDENT>arr = arr.ravel()<EOL><DEDENT>ndim = arr.ndim<EOL>axis = ndim - <NUM_LIT:1><EOL><DEDENT>if ndim == <NUM_LIT:0>:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", DeprecationWarning)<EOL>if wrap:<EOL><INDENT>return wrap(arr)<EOL><DEDENT>else:<EOL><INDENT>return arr.copy()<EOL><DEDENT><DEDENT>slobj = [slice(None)]*ndim<EOL>N = arr.shape[axis]<EOL>newshape = list(arr.shape)<EOL>if isinstance(obj, slice):<EOL><INDENT>start, stop, step = obj.indices(N)<EOL>xr = range(start, stop, step)<EOL>numtodel = len(xr)<EOL>if numtodel <= <NUM_LIT:0>:<EOL><INDENT>if wrap:<EOL><INDENT>return wrap(arr.copy())<EOL><DEDENT>else:<EOL><INDENT>return arr.copy()<EOL><DEDENT><DEDENT>if step < <NUM_LIT:0>:<EOL><INDENT>step = -step<EOL>start = xr[-<NUM_LIT:1>]<EOL>stop = xr[<NUM_LIT:0>] + <NUM_LIT:1><EOL><DEDENT>newshape[axis] -= numtodel<EOL>new = empty(newshape, arr.dtype, arr.flags.fnc)<EOL>if start == <NUM_LIT:0>:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>slobj[axis] = slice(None, start)<EOL>new[slobj] = arr[slobj]<EOL><DEDENT>if stop == N:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>slobj[axis] = slice(stop-numtodel, None)<EOL>slobj2 = [slice(None)]*ndim<EOL>slobj2[axis] = slice(stop, None)<EOL>new[slobj] = arr[slobj2]<EOL><DEDENT>if step == <NUM_LIT:1>:<EOL><INDENT>pass<EOL><DEDENT>else:  <EOL><INDENT>keep = ones(stop-start, dtype=bool)<EOL>keep[:stop-start:step] = False<EOL>slobj[axis] = slice(start, stop-numtodel)<EOL>slobj2 = [slice(None)]*ndim<EOL>slobj2[axis] = slice(start, stop)<EOL>arr = arr[slobj2]<EOL>slobj2[axis] = keep<EOL>new[slobj] = arr[slobj2]<EOL><DEDENT>if wrap:<EOL><INDENT>return wrap(new)<EOL><DEDENT>else:<EOL><INDENT>return new<EOL><DEDENT><DEDENT>_obj = obj<EOL>obj = np.asarray(obj)<EOL>if obj.dtype == bool:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", FutureWarning)<EOL>obj = obj.astype(intp)<EOL><DEDENT>if isinstance(_obj, (int, long, integer)):<EOL><INDENT>obj = obj.item()<EOL>if (obj < -N or obj >= N):<EOL><INDENT>raise IndexError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (obj, axis, N))<EOL><DEDENT>if (obj < <NUM_LIT:0>):<EOL><INDENT>obj += N<EOL><DEDENT>newshape[axis] -= <NUM_LIT:1><EOL>new = empty(newshape, arr.dtype, arr.flags.fnc)<EOL>slobj[axis] = slice(None, obj)<EOL>new[slobj] = arr[slobj]<EOL>slobj[axis] = slice(obj, None)<EOL>slobj2 = [slice(None)]*ndim<EOL>slobj2[axis] = slice(obj+<NUM_LIT:1>, None)<EOL>new[slobj] = arr[slobj2]<EOL><DEDENT>else:<EOL><INDENT>if obj.size == <NUM_LIT:0> and not isinstance(_obj, np.ndarray):<EOL><INDENT>obj = obj.astype(intp)<EOL><DEDENT>if not np.can_cast(obj, intp, '<STR_LIT>'):<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", DeprecationWarning)<EOL>obj = obj.astype(intp)<EOL><DEDENT>keep = ones(N, dtype=bool)<EOL>inside_bounds = (obj < N) & (obj >= -N)<EOL>if not inside_bounds.all():<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>DeprecationWarning)<EOL>obj = obj[inside_bounds]<EOL><DEDENT>positive_indices = obj >= <NUM_LIT:0><EOL>if not positive_indices.all():<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", FutureWarning)<EOL>obj = obj[positive_indices]<EOL><DEDENT>keep[obj, ] = False<EOL>slobj[axis] = keep<EOL>new = arr[slobj]<EOL><DEDENT>if wrap:<EOL><INDENT>return wrap(new)<EOL><DEDENT>else:<EOL><INDENT>return new<EOL><DEDENT>
Return a new array with sub-arrays along an axis deleted. For a one
dimensional array, this returns those entries not returned by
`arr[obj]`.

Parameters
----------
arr : array_like
  Input array.
obj : slice, int or array of ints
  Indicate which sub-arrays to remove.
axis : int, optional
  The axis along which to delete the subarray defined by `obj`.
  If `axis` is None, `obj` is applied to the flattened array.

Returns
-------
out : ndarray
    A copy of `arr` with the elements specified by `obj` removed. Note
    that `delete` does not occur in-place. If `axis` is None, `out` is
    a flattened array.

See Also
--------
insert : Insert elements into an array.
append : Append elements at the end of an array.

Notes
-----
Often it is preferable to use a boolean mask. For example:

>>> mask = np.ones(len(arr), dtype=bool)
>>> mask[[0,2,4]] = False
>>> result = arr[mask,...]

Is equivalent to `np.delete(arr, [0,2,4], axis=0)`, but allows further
use of `mask`.

Examples
--------
>>> arr = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
>>> arr
array([[ 1,  2,  3,  4],
       [ 5,  6,  7,  8],
       [ 9, 10, 11, 12]])
>>> np.delete(arr, 1, 0)
array([[ 1,  2,  3,  4],
       [ 9, 10, 11, 12]])

>>> np.delete(arr, np.s_[::2], 1)
array([[ 2,  4],
       [ 6,  8],
       [10, 12]])
>>> np.delete(arr, [1,3,5], None)
array([ 1,  3,  5,  7,  8,  9, 10, 11, 12])