On Fri, Jul 18, 2008 at 2:49 PM, Andrew Straw <[EMAIL PROTECTED]> wrote: > I just spent a little time getting hexbin to discard nans without > failing in mysterious ways. > > I'm sending 2 patches: one will detect nans and raise a suitable > exception. The other will automatically drop the nans and continue with > hexbin. The 2nd seems a little nicer in functionality, but the code is a > little more convoluted and hence more brittle, and so I'm torn as to > which I'd prefer. (The problem with just detecting nans from the > beginning is that it would cause an extra pass through the data in all > cases.)
I think the nans should be dropped with no raise or warning, which is consistent with our handling elsewhere. I don't think your approach, which if I am reading this correctly assumes that is x or y has nans then the min or max will be nan, is correct. Eg, In [51]: x = np.random.rand(10) In [52]: x[4] = np.nan In [53]: x.min() Out[53]: 0.37072898459621617 In [54]: x.max() Out[54]: 0.79367039009185769 I think min and max in the presence of nans is undefined. But you can just pay for the extra pass mask = np.isnan(x) & np.isnan(y) if mask.any(): # mask where JDH ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel