pyyeti.locate.list_intersect

pyyeti.locate.list_intersect(L1, L2)[source]

Get list intersection partition vectors between two lists

Parameters:
  • L1 (list) – List 1; the output vectors maintain the order of L1.

  • L2 (list) – List 2.

Returns:

  • pv1 (1d ndarray) – Index vector into L1.

  • pv2 (1d ndarray) – Index vector into L2.

Notes

pv1 and pv2 are found such that:

[L1[i] for i in pv1] == [L2[i] for i in pv2]

Examples

>>> from pyyeti import locate
>>> pv1, pv2 = locate.list_intersect(['a', 3, 'z', 0],
...                                  [0, 'z', 1, 'a'])
>>> pv1
array([0, 2, 3]...)
>>> pv2
array([3, 1, 0]...)
>>> locate.list_intersect(['a', 'b'],
...                       [1, 2])
(array([], dtype=int...), array([], dtype=int...))