flopscope.

flopscope.numpy.array_equiv

fnp.array_equiv(a1, a2)[flopscope source][numpy source]

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

Adapted from NumPy docs np.array_equiv

Areacore
Typecustom
Cost
per-operation
Flopscope Context

Element-wise equivalence; cost = numel(a).

Shape consistent means they are either the same shape, or one input array can be broadcasted to create the same shape as the other one.

Parameters

a1, a2:array_like

Input arrays.

Returns

out:bool

True if equivalent, False otherwise.

Examples

>>> import flopscope.numpy as fnp
>>> flops.array_equiv([1, 2], [1, 2])
True
>>> flops.array_equiv([1, 2], [1, 3])
False

Showing the shape equivalence:

>>> flops.array_equiv([1, 2], [[1, 2], [1, 2]])
True
>>> flops.array_equiv([1, 2], [[1, 2, 1, 2], [1, 2, 1, 2]])
False
>>> flops.array_equiv([1, 2], [[1, 2], [1, 3]])
False