Alan G Isaac wrote:
> On 6/4/2009 10:50 AM josef.p...@gmail.com apparently wrote:
>> intersect1d gives set intersection if both arrays have 
>> only unique elements (i.e. are sets).  I thought the 
>> naming is pretty clear:
> 
>> intersect1d(a,b)   set intersection if a and b with unique elements 
>> intersect1d_nu(a,b)   set intersection if a and b with non-unique elements 
>> setmember1d(a,b)  boolean index array for a of set intersection if a 
>> and b with unique elements 
>> setmember1d_nu(a,b)  boolean index array for a of set intersection if 
>> a and b with non-unique elements 
> 
> 
>>>> a
> array([1, 1, 2, 3, 3, 4])
>>>> b
> array([1, 4, 4, 4])
>>>> np.intersect1d_nu(a,b)
> array([1, 4])
> 
> That is, intersect1d_nu is the actual set intersection
> function.  (I.e., intersect1d and intersect1d_nu would most
> naturally have swapped names.)  That is why the appended _nu
> will not communicate what was intended.  (I.e.,
> setmember1d_nu will not be a match for intersect1d_nu.)

The naming should express this: intersect1d expects its arguments are 
sets, intersect1d_nu does not. A set has unique elements by definition.

cheers,
r.
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to