__mod__¶
- array.__mod__(other: int | float | array, /) array ¶
Evaluates
self_i % other_i
for each element of an array instance with the respective element of the arrayother
.Note
For input arrays which promote to an integer data type, the result of division by zero is unspecified and thus implementation-defined.
Special Cases
Note
In general, this method is not recommended for floating-point operands as semantics do not follow IEEE 754. That this method is specified to accept floating-point operands is primarily for reasons of backward compatibility.
For floating-point operands, let
self
equalx1
andother
equalx2
.If either
x1_i
orx2_i
isNaN
, the result isNaN
.If
x1_i
is either+infinity
or-infinity
andx2_i
is either+infinity
or-infinity
, the result isNaN
.If
x1_i
is either+0
or-0
andx2_i
is either+0
or-0
, the result isNaN
.If
x1_i
is+0
andx2_i
is greater than0
, the result is+0
.If
x1_i
is-0
andx2_i
is greater than0
, the result is+0
.If
x1_i
is+0
andx2_i
is less than0
, the result is-0
.If
x1_i
is-0
andx2_i
is less than0
, the result is-0
.If
x1_i
is greater than0
andx2_i
is+0
, the result isNaN
.If
x1_i
is greater than0
andx2_i
is-0
, the result isNaN
.If
x1_i
is less than0
andx2_i
is+0
, the result isNaN
.If
x1_i
is less than0
andx2_i
is-0
, the result isNaN
.If
x1_i
is+infinity
andx2_i
is a positive (i.e., greater than0
) finite number, the result isNaN
.If
x1_i
is+infinity
andx2_i
is a negative (i.e., less than0
) finite number, the result isNaN
.If
x1_i
is-infinity
andx2_i
is a positive (i.e., greater than0
) finite number, the result isNaN
.If
x1_i
is-infinity
andx2_i
is a negative (i.e., less than0
) finite number, the result isNaN
.If
x1_i
is a positive (i.e., greater than0
) finite number andx2_i
is+infinity
, the result isx1_i
. (note: this result matches Python behavior.)If
x1_i
is a positive (i.e., greater than0
) finite number andx2_i
is-infinity
, the result isx2_i
. (note: this result matches Python behavior.)If
x1_i
is a negative (i.e., less than0
) finite number andx2_i
is+infinity
, the result isx2_i
. (note: this results matches Python behavior.)If
x1_i
is a negative (i.e., less than0
) finite number andx2_i
is-infinity
, the result isx1_i
. (note: this result matches Python behavior.)In the remaining cases, the result must match that of the Python
%
operator.
- Parameters:
self (array) – array instance. Should have a numeric data type.
other (Union[int, float, array]) – other array. Must be compatible with
self
(see Broadcasting). Should have a numeric data type.
- Returns:
out (array) – an array containing the element-wise results. Each element-wise result must have the same sign as the respective element
other_i
. The returned array must have a floating-point data type determined by Type Promotion Rules.
Note
Element-wise results must equal the results returned by the equivalent element-wise function
remainder()
.