Logic functions

Truth value testing

all

Test whether all array elements along a given axis evaluate to True.

any

Test whether any array element along a given axis evaluates to True.

Array contents

isfinite

Test each element \(x_i\) of the input array x to determine if finite.

isinf

Tests each element \(x_i\) of the input array x to determine if equal to positive or negative infinity.

isnan

Tests each element \(x_i\) of the input array x to determine whether the element is NaN.

isneginf

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

isposinf

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

Array type testing

iscomplex

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

iscomplexobj

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

isfortran

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

isreal

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

isrealobj

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

isscalar

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

Logical operations

logical_and

Computes the logical AND for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2.

logical_or

Computes the logical OR for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2.

logical_not

Computes the logical NOT for each element \(x_i\) of input array x.

logical_xor

Computes the logical XOR for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2.

Comparison

allclose

Returns True if two arrays are element-wise equal within a tolerance.

isclose

Returns a boolean array where two arrays are element-wise equal within a tolerance.

array_equal

True if two arrays have the same shape and elements, False otherwise.

array_equiv

Returns True if input arrays are shape consistent and all elements equal.

greater

Computes the greater-than test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2.

greater_equal

Computes the greater-than or equal-to test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2.

less

Computes the less-than test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2.

less_equal

Computes the less-than or equal-to test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2.

equal

Calculates equality test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2.

not_equal

Calculates inequality test results for each element \(x1_i\) of the input array x1 with the respective element \(x2_i\) of the input array x2.