From 5872d340c7a142ad6117ff080cdb70a89a7f70a4 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@8a9318a1-56ba-4d59-b755-99d26321be01> Date: Mon, 31 Aug 2009 22:23:52 +0000 Subject: [PATCH] changing how data types are handled in data comparison git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@77 8a9318a1-56ba-4d59-b755-99d26321be01 --- pyglance/glance/delta.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyglance/glance/delta.py b/pyglance/glance/delta.py index cc5bfd1..50f5ed8 100644 --- a/pyglance/glance/delta.py +++ b/pyglance/glance/delta.py @@ -37,7 +37,7 @@ def diff(aData, bData, epsilon=0., """ shape = aData.shape assert(bData.shape==shape) - assert(aData.dtype==bData.dtype) + assert(can_cast(aData.dtype, bData.dtype) or can_cast(bData.dtype, aData.dtype)) # if the ignore masks do not exist, set them to include none of the data if (ignore_mask_a is None) : @@ -61,8 +61,14 @@ def diff(aData, bData, epsilon=0., valid_in_b_mask = ~(b_not_finite_mask | b_missing_mask | ignore_mask_b) valid_in_both = valid_in_a_mask & valid_in_b_mask + # figure out our shared data type + sharedType = aData.dtype + if (aData.dtype is not bData.dtype) : + sharedType = common_type(aData, bData) + LOG.debug('Shared data type that will be used for diff comparison: ' + str(sharedType)) + # construct our diff'ed array - raw_diff = empty_like(aData) + raw_diff = zeros(shape, dtype=sharedType) #empty_like(aData) raw_diff[~valid_in_both] = nan # throw away invalid data raw_diff[valid_in_both] = bData[valid_in_both] - aData[valid_in_both] -- GitLab