API References

ismember.ismember.ismember(a_vec, b_vec, method=None)

Ismember: MATLAB equivalent function

Description

MATLAB equivalent ismember function [LIA, LOCB] = ISMEMBER(A,B) also returns an array LOCB containing the lowest absolute index in B for each element in A which is a member of B and 0 if there is no such index.

param a_vec

type a_vec

list or array

param b_vec

type b_vec

list or array

param method

‘elementwise’: For each row, all elements are compared. ‘rows’: Row-wise matrice comparison.

type method

[None, ‘rows’, ‘elementwise’] (default: None).

param Returns an array containing logical 1 (true) where the data in A is found in B. Elsewhere

:param : :param the array contains logical 0 (false): :param ——-: :param Tuple:

Example

>>> a_vec = np.array([1,2,3,None])
>>> b_vec = np.array([4,1,2])
>>> Iloc, idx = ismember(a_vec,b_vec)
>>> a_vec[Iloc] == b_vec[idx]
>>>
>>> # Row wise comparison
>>> a_vec = np.array(((1, 2, 3), (4, 5, 6), (7, 8, 9), (10, 11, 12)))
>>> b_vec = np.array(((4, 5, 6), (7, 8, 0)))
>>> Iloc, idx = ismember(a_vec, b_vec, 'rows')
>>> a_vec[Iloc]==b_vec[idx]

References