Logic functions

Truth value testing

methoddescription
allopen in new window(a[, axis, out, keepdims])Test whether all array elements along a given axis evaluate to True.
anyopen in new window(a[, axis, out, keepdims])Test whether any array element along a given axis evaluates to True.

Array contents

methoddescription
isfiniteopen in new window(x, /[, out, where, casting, order, …])Test element-wise for finiteness (not infinity or not Not a Number).
isinfopen in new window(x, /[, out, where, casting, order, …])Test element-wise for positive or negative infinity.
isnanopen in new window(x, /[, out, where, casting, order, …])Test element-wise for NaN and return result as a boolean array.
isnatopen in new window(x, /[, out, where, casting, order, …])Test element-wise for NaT (not a time) and return result as a boolean array.
isneginfopen in new window(x[, out])Test element-wise for negative infinity, return result as bool array.
isposinfopen in new window(x[, out])Test element-wise for positive infinity, return result as bool array.

Array type testing

methoddescription
iscomplexopen in new window(x)Returns a bool array, where True if input element is complex.
iscomplexobjopen in new window(x)Check for a complex type or an array of complex numbers.
isfortranopen in new window(a)Check if the array is Fortran contiguous but not C contiguous.
isrealopen in new window(x)Returns a bool array, where True if input element is real.
isrealobjopen in new window(x)Return True if x is a not complex type or an array of complex numbers.
isscalaropen in new window(num)Returns True if the type of num is a scalar type.

Logical operations

methoddescription
logical_andopen in new window(x1, x2, /[, out, where, …])Compute the truth value of x1 AND x2 element-wise.
logical_oropen in new window(x1, x2, /[, out, where, casting, …])Compute the truth value of x1 OR x2 element-wise.
logical_notopen in new window(x, /[, out, where, casting, …])Compute the truth value of NOT x element-wise.
logical_xoropen in new window(x1, x2, /[, out, where, …])Compute the truth value of x1 XOR x2, element-wise.

Comparison

methoddescription
allcloseopen in new window(a, b[, rtol, atol, equal_nan])Returns True if two arrays are element-wise equal within a tolerance.
iscloseopen in new window(a, b[, rtol, atol, equal_nan])Returns a boolean array where two arrays are element-wise equal within a tolerance.
array_equalopen in new window(a1, a2)True if two arrays have the same shape and elements, False otherwise.
array_equivopen in new window(a1, a2)Returns True if input arrays are shape consistent and all elements equal.
greateropen in new window(x1, x2, /[, out, where, casting, …])Return the truth value of (x1 > x2) element-wise.
greater_equalopen in new window(x1, x2, /[, out, where, …])Return the truth value of (x1 >= x2) element-wise.
lessopen in new window(x1, x2, /[, out, where, casting, …])Return the truth value of (x1 < x2) element-wise.
less_equalopen in new window(x1, x2, /[, out, where, casting, …])Return the truth value of (x1 =< x2) element-wise.
equalopen in new window(x1, x2, /[, out, where, casting, …])Return (x1 == x2) element-wise.
not_equalopen in new window(x1, x2, /[, out, where, casting, …])Return (x1 != x2) element-wise.