Logic functions — NumPy v2.6.dev0 Manual

Truth value testing

#

Array contents

#

isfinite

(x, /[, out, where, casting, order, ...])

Test element-wise for finiteness (not infinity and not Not a Number).

isinf

(x, /[, out, where, casting, order, ...])

Test element-wise for positive or negative infinity.

isnan

(x, /[, out, where, casting, order, ...])

Test element-wise for NaN and return result as a boolean array.

isnat

(x, /[, out, where, casting, order, ...])

Test element-wise for NaT (not a time) and return result as a boolean array.

isneginf

(x[, out])

Test element-wise for negative infinity, return result as bool array.

isposinf

(x[, out])

Test element-wise for positive infinity, return result as bool array.

Array type testing

#

iscomplex

(x)

Returns a bool array, where True if input element is complex.

iscomplexobj

(x)

Check for a complex type or an array of complex numbers.

isfortran

(a)

Check if the array is Fortran contiguous but not C contiguous.

isreal

(x)

Returns a bool array, where True if input element is real.

isrealobj

(x)

Return True if x is a not complex type or an array of complex numbers.

isscalar

(element)

Returns True if the type of element is a scalar type.

Logical operations

#

Comparison

#

greater

(x1, x2, /[, out, where, casting, ...])

Return the truth value of (x1 > x2) element-wise.

greater_equal

(x1, x2, /[, out, where, ...])

Return the truth value of (x1 >= x2) element-wise.

less

(x1, x2, /[, out, where, casting, ...])

Return the truth value of (x1 < x2) element-wise.

less_equal

(x1, x2, /[, out, where, casting, ...])

Return the truth value of (x1 <= x2) element-wise.

equal

(x1, x2, /[, out, where, casting, ...])

Return (x1 == x2) element-wise.

not_equal

(x1, x2, /[, out, where, casting, ...])

Return (x1 != x2) element-wise.