def find_common_elements(source_preferences, target_preferences):
 src = dict(source_preferences)
 tgt = dict(target_preferences)
 inter = np.intersect1d(src.keys(), tgt.keys())
 common_preferences = zip(*[(src[item], tgt[item]) for item in inter if ((not np.isnan(src[item])) and (not np.isnan(tgt[item])))])
 if common_preferences:
  return (np.asarray([common_preferences[0]]), np.asarray([common_preferences[1]]))
 else:
  return (np.asarray([[]]), np.asarray([[]]))

def find_common_elements ( source_preferences , target_preferences ) : src = dict ( source_preferences ) tgt = dict ( target_preferences ) inter = np . intersect1d ( src . keys ( ) , tgt . keys ( ) ) common_preferences = zip ( * [ ( src [ item ] , tgt [ item ] ) for item in inter if ( ( not np . isnan ( src [ item ] ) ) and ( not np . isnan ( tgt [ item ] ) ) ) ] ) if common_preferences : return ( np . asarray ( [ common_preferences [ 0 ] ] ) , np . asarray ( [ common_preferences [ 1 ] ] ) ) else : return ( np . asarray ( [ [ ] ] ) , np . asarray ( [ [ ] ] ) )
returns the preferences from both vectors .