Remove masked elements from an array
Fernando Pérez
fperez528 at yahoo.com
Mon Apr 29 21:34:25 EDT 2002
James J. Besemer wrote:
>> No, please heed other advice and use the MA approach. Please note that I'm
>> not dissing this post on its own merits, it's a nice discussion, it just is
>> ill-adapted to numeric processing. Numeric provides its own fast way to
>> manipulate arrays with invalid data, by all means use it. After all, speed
>> is one of the big reasons why you use Numeric to begin with (you could do
>> most things in it with regular lists, if you had the age of the universe to
>> wait).
>
> I would agree with you that it might be worth the extra trouble and effort
> to download, install and learn to use Numerics IF the user in question has a
> big, production application to run.
>
Quoting the original post:
I have a Numeric array with missing elements from which I wish to calculate
a histogram. However, in order to do so I must first remove the 'None'
values from the array. I have a kludgy solution, but I was wondering if
someone could point me in the right direction on what is the proper method
of collapsing a masked array to just the non-masked values.
/quote
That's why I emphasized to him using Numeric's masked array facilities:
_because_ he said he was using Numeric to begin with (unless his use of
'Numeric array' with a capital N misled me, and he just means 'a list with
numbers in it' ;). All in all I liked the thread because it exposed valuable
alternative approaches to a problem, and that's always a good way to learn.
But I assume that if the OP was using Numeric to begin with, performance
probably is a concern to him in the first place.
Otherwise I was happy to read the various alternatives proposed.
cheers,
f.
More information about the Python-list
mailing list