[Numpy-discussion] applying function under certain conditions

Christian Meesters meesters at uni-mainz.de
Fri May 20 05:31:26 EDT 2005


Hi

I have a large 1D numarray array with some huge values and lots of 
zeros. Now, for better representation I wanted to plot the logarithm. 
Well, calculating the logarithm is not such a good idea if you have 
zeros in your array ...
However, how do you implement such cases like "only apply a function if 
a certain condition is true", I'd like to ask whether there are nice 
short snippets which could show such cases. My own code is 
(unnecessarily?) long and ugly. I tried to combine 'where' and 
'greater', but didn't succeed. I guess I'm just don't see the wood for 
the trees. How would you write this in my case?

TIA
Regards,
Christian





More information about the NumPy-Discussion mailing list