From 36d70fc21708d022e0317509a6d633b06742311f Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@8a9318a1-56ba-4d59-b755-99d26321be01> Date: Tue, 25 Aug 2009 18:42:26 +0000 Subject: [PATCH] correcting the min/max with mask functions to handle completely masked arrays git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@64 8a9318a1-56ba-4d59-b755-99d26321be01 --- pyglance/glance/delta.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pyglance/glance/delta.py b/pyglance/glance/delta.py index 65ccf37..ee0c453 100644 --- a/pyglance/glance/delta.py +++ b/pyglance/glance/delta.py @@ -280,11 +280,19 @@ def _get_numerical_data_stats(a, b, diff_data, data_is_finite_mask, outside_epsi # get the min, ignoring the stuff in mask def min_with_mask(data, mask) : - return data[~mask][data[~mask].argmin()] - + temp = data[~mask] + toReturn = nan + if len(temp) > 0 : + toReturn = temp[temp.argmin()] + return toReturn + # get the max, ignoring the stuff in mask def max_with_mask(data, mask) : - return data[~mask][data[~mask].argmax()] + temp = data[~mask] + toReturn = nan + if len(temp) > 0 : + toReturn = temp[temp.argmax()] + return toReturn def summarize(a, b, epsilon=0., (a_missing_value, b_missing_value)=(None,None), ignoreInAMask=None, ignoreInBMask=None): """return dictionary of statistics dictionaries -- GitLab