[Numpy-discussion] extract elements of an array that are contained in another array?

Anne Archibald peridot.faceted at gmail.com
Thu Jun 4 16:38:40 EDT 2009

2009/6/4  <josef.pktd at gmail.com>:

> intersect1d should throw a domain error if you give it arrays with
> non-unique elements, which is not done for speed reasons

It seems to me that this is the basic source of the problem. Perhaps
this can be addressed? I realize maintaining compatibility with the
current behaviour is necessary, so how about a multistage deprecation:

1. add a keyword argument to intersect1d "assume_unique"; if it is not
present, check for uniqueness and emit a warning if not unique
2. change the warning to an exception
3. change the meaning of the function to that of intersect1d_nu if the
keyword argument is not present

One could do something similar with setmember1d.

This would remove the pitfall of the 1d assumption and the wart of the
_nu names without hampering performance for people who know they have
unique arrays and are in a hurry.


More information about the NumPy-Discussion mailing list