Create a gist now

Instantly share code, notes, and snippets.

Get common or overlap values among two list values
import numpy
def getOverlap(a, b):
Inputs : a, b are lists of input values
Returns : Return array with values common or overlap between a and b.
If common is not found among a and b, then that indecies values
will be masked.
Written By : Arulalan.T
Date : 01.09.2014
if len(a) != len(b):
raise ValueError("Length must be same")
c = []
for i, j in zip(a, b):
if i > 0 and j > 0:
c.append(min(i, j))
elif i < 0 and j < 0:
c.append(max(i, j))
elif ((i > 0 and j < 0) or (i < 0 and j > 0)):
# end of for i, j in zip(a, b):
c =
c.mask = c == 0
return c
# end of def getOverlap(a, b):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment