invert_no_zero#
- caput.algorithms.invert_no_zero(x: numpy.typing.ArrayLike, out: numpy.typing.ArrayLike | None = None) numpy.typing.ArrayLike[source]#
Return the reciprocal, but ignoring zeros.
Where
x != 0return1/x; wherex == 0, return 0. Importantly this routine does not produce a warning about zero division.- Parameters:
- xarray_like
Array to invert
- outarray_like, optional
Output array where the result is stored. Default is None, in which case a new array is created.
- Returns:
- outarray_like
The reciprocal of x. Where possible the output has the same memory layout as the input, if this cannot be preserved the output is C-contiguous. If out was not None, this is out.