Changeset 1b1a1c1 in sasview


Ignore:
Timestamp:
Oct 7, 2016 11:28:39 AM (8 years ago)
Author:
mathieu
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
dd72190
Parents:
286c757
Message:

Add tolerance to data ops. Fixes #493

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/data_info.py

    r45d7662 r1b1a1c1  
    881881                raise ValueError, msg 
    882882            # Here we could also extrapolate between data points 
    883             ZERO = 1.0e-12 
     883            TOLERANCE = 0.01 
    884884            for i in range(len(self.x)): 
    885                 if math.fabs(self.x[i] - other.x[i]) > ZERO: 
     885                if math.fabs((self.x[i] - other.x[i])/self.x[i]) > TOLERANCE: 
    886886                    msg = "Incompatible data sets: x-values do not match" 
    887887                    raise ValueError, msg 
     
    10931093        """ 
    10941094        err_other = None 
     1095        TOLERANCE = 0.01 
    10951096        if isinstance(other, Data2D): 
    10961097            # Check that data lengths are the same 
     
    11011102                raise ValueError, msg 
    11021103            for ind in range(len(self.data)): 
    1103                 if self.qx_data[ind] != other.qx_data[ind]: 
    1104                     msg = "Incompatible data sets: qx-values do not match" 
     1104                if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) > TOLERANCE: 
     1105                    msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 
    11051106                    raise ValueError, msg 
    1106                 if self.qy_data[ind] != other.qy_data[ind]: 
    1107                     msg = "Incompatible data sets: qy-values do not match" 
     1107                if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) > TOLERANCE: 
     1108                    msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 
    11081109                    raise ValueError, msg 
    11091110 
Note: See TracChangeset for help on using the changeset viewer.