Set operations in Numeric

G

George Sakkis

Is there a way to handle numeric (or numarray or numpy) arrays as sets
and compute efficiently their intersection, union, etc. ? I hope there
is a faster way than s = array(set(A) & set(B)). Can this be done with
masked arrays maybe ? I've never used them though and browsing through
the docs didn't make clear if it is possible.

Thanks,
George
 
R

Robert Kern

George said:
Is there a way to handle numeric (or numarray or numpy) arrays as sets
and compute efficiently their intersection, union, etc. ? I hope there
is a faster way than s = array(set(A) & set(B)). Can this be done with
masked arrays maybe ? I've never used them though and browsing through
the docs didn't make clear if it is possible.

You'll probably want to ask such questions on the numpy list:

http://www.scipy.org/Mailing_Lists

Robert Cimrman has implemented a number of set operations based on sorting.

http://svn.scipy.org/svn/scipy/trunk/Lib/sandbox/arraysetops/arraysetops.py

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top