Mercurial > pylearn
annotate misc.py @ 88:6749d18e11c8
bugfix as numpy numpy don't support self.data[[i1,...],[i2,...]] when their is more then two i1 and i2
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Mon, 05 May 2008 14:51:41 -0400 |
parents | 718befdc8671 |
children | e9a95e19e6f8 |
rev | line source |
---|---|
49
718befdc8671
Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff
changeset
|
1 |
718befdc8671
Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff
changeset
|
2 def unique_elements_list_intersection(list1,list2): |
718befdc8671
Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff
changeset
|
3 """ |
718befdc8671
Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff
changeset
|
4 Return the unique elements that are in both list1 and list2 |
718befdc8671
Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff
changeset
|
5 (repeated elements in listi will not be duplicated in the result). |
718befdc8671
Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff
changeset
|
6 This should run in O(n1+n2) where n1=|list1|, n2=|list2|. |
718befdc8671
Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff
changeset
|
7 """ |
718befdc8671
Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff
changeset
|
8 return list(set.intersection(set(list1),set(list2))) |