Changeset debf5c3 in sasview for src/sas/qtgui/SlitSizeCalculator.py


Ignore:
Timestamp:
Dec 14, 2016 2:19:57 AM (5 years ago)
Author:
wojciech
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:
ab9984e
Parents:
3a0ce4f
Message:

Addded tests for raised exceptions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/SlitSizeCalculator.py

    r3a0ce4f rdebf5c3  
    33from UI.SlitSizeCalculator import Ui_SlitSizeCalculator 
    44from sas.sascalc.dataloader.loader import Loader 
    5 from sas.sasgui.guiframe.dataFitting import Data1D 
    6 from sas.sasgui.guiframe.dataFitting import Data2D 
    75from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator 
    86 
     
    119 
    1210class SlitSizeCalculator(QtGui.QDialog, Ui_SlitSizeCalculator): 
     11    """ 
     12    Provides the slit length calculator GUI. 
     13    """ 
    1314    def __init__(self, parent=None): 
    1415        super(SlitSizeCalculator, self).__init__() 
     
    3132    def onHelp(self): 
    3233        """ 
    33         Bring up the Kiessig fringe calculator Documentation whenever 
     34        Bring up the Slit Size Calculator calculator Documentation whenever 
    3435        the HELP button is clicked. 
    3536        Calls DocumentationWindow with the path of the location within the 
     
    4849    def onBrowse(self): 
    4950        """ 
    50         Execute the computation of thickness 
     51        Browse the file and calculate slit lenght upon loading 
    5152        """ 
    5253        path_str = self.chooseFile() 
     
    5758 
    5859        self.data_file.setText(os.path.basename(path_str)) 
    59         #We are loading data for one model only therefor index 0 
    6060        self.calculateSlitSize(data) 
    6161 
     
    7070                "SAXSess 1D data (*.txt *.TXT *.dat *.DAT)", None, 
    7171                QtGui.QFileDialog.DontUseNativeDialog) 
     72 
    7273        if path is None: 
    7374            return 
     
    8687    def calculateSlitSize(self, data=None): 
    8788        """ 
    88             Complete the loading and compute the slit size 
     89        Computes slit lenght from given 1D data 
    8990        """ 
    9091 
     
    9394            raise RuntimeError, msg 
    9495 
    95         if isinstance(data, Data2D) or data.__class__.__name__ == 'Data2D': 
     96        if data.__class__.__name__ == 'Data2D': 
    9697            msg = "Slit Length cannot be computed for 2D Data" 
    9798            raise Exception, msg 
     
    101102             x = data.x 
    102103             y = data.y 
    103              if x == [] or  x is None or y == [] or y is None: 
     104             if x == [] or x is None or y == [] or y is None: 
    104105                 msg = "The current data is empty please check x and y" 
    105106                 raise ValueError, msg 
     
    113114        slit_length_str = "{:.5f}".format(slit_length) 
    114115        self.slit_length_out.setText(slit_length_str) 
    115         #Display unit 
     116 
     117        #Display unit, which most likely needs to be 1/Ang but needs to be confirmed 
    116118        self.unit_out.setText("[Unknown]") 
    117119 
Note: See TracChangeset for help on using the changeset viewer.