Changeset 0261bc1 in sasview for src/sas/qtgui/Utilities/GuiUtils.py


Ignore:
Timestamp:
Nov 20, 2017 5:55:30 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
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
Children:
f1ec901
Parents:
6a3e1fe
Message:

Added unit tests for recent functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Utilities/GuiUtils.py

    r6a3e1fe r0261bc1  
    271271    """ 
    272272    def __init__(self, parent=None): 
    273         super(QtGui.QStandardItem, self).__init__() 
     273        super(HashableStandardItem, self).__init__() 
    274274 
    275275    def __hash__(self): 
     
    277277        #return hash(self.__init__) 
    278278        return 0 
     279 
     280    def clone(self): 
     281        ''' Assure __hash__ is cloned as well''' 
     282        clone = super(HashableStandardItem, self).clone() 
     283        clone.__hash__ = self.__hash__ 
     284        return clone 
    279285 
    280286 
     
    561567    with open(path,'w') as out: 
    562568        has_errors = True 
    563         if data.dy is None or not data.dy: 
     569        if data.dy is None or not data.dy.any(): 
    564570            has_errors = False 
    565571        # Sanity check 
     
    571577                has_errors = False 
    572578        if has_errors: 
    573             if data.dx is not None and data.dx: 
     579            if data.dx is not None and data.dx.any(): 
    574580                out.write("<X>   <Y>   <dY>   <dX>\n") 
    575581            else: 
     
    580586        for i in range(len(data.x)): 
    581587            if has_errors: 
    582                 if data.dx is not None and data.dx: 
     588                if data.dx is not None and data.dx.any(): 
    583589                    if  data.dx[i] is not None: 
    584590                        out.write("%g  %g  %g  %g\n" % (data.x[i], 
     
    857863        return value[0] 
    858864    else: 
    859         raise ValueError 
     865        raise TypeError 
    860866 
    861867class DoubleValidator(QtGui.QDoubleValidator): 
     
    867873        Return invalid for commas 
    868874        """ 
    869         if (',' in input): 
     875        if input is not None and ',' in input: 
    870876            return (QtGui.QValidator.Invalid, input, pos) 
    871877        return super(DoubleValidator, self).validate(input, pos) 
     
    875881        Correct (remove) potential preexisting content 
    876882        """ 
    877         QtGui.QDoubleValidator.fixup(input) 
     883        super(DoubleValidator, self).fixup(input) 
    878884        input = input.replace(",", "") 
    879885 
Note: See TracChangeset for help on using the changeset viewer.