numpy.mod(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'remainder'>
Return element-wise remainder of division.
Computes the remainder complementary to the floor_divide
function. It is equivalent to the Python modulus operator``x1 % x2`` and has the same sign as the divisor x2
. It should not be confused with the Matlab(TM) rem
function.
Parameters: |
x1 : array_like Dividend array. x2 : array_like Divisor array. out : ndarray, None, or tuple of ndarray and None, optional A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or where : array_like, optional Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone. **kwargs For other keyword-only arguments, see the ufunc docs. |
---|---|
Returns: |
y : ndarray The element-wise remainder of the quotient |
See also
floor_divide
//
operator.divmod
fmod
rem
function.Returns 0 when x2
is 0 and both x1
and x2
are (arrays of) integers.
>>> np.remainder([4, 7], [2, 3]) array([0, 1]) >>> np.remainder(np.arange(7), 5) array([0, 1, 2, 3, 4, 0, 1])
© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.mod.html