Ignore:
File:
1 edited

Legend:

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

    r3b8cc00 r38f838e  
    1111from sas.sascalc.fit import models 
    1212 
    13 import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    1413from sas.qtgui.Utilities.UI.TabbedModelEditor import Ui_TabbedModelEditor 
    1514from sas.qtgui.Utilities.PluginDefinition import PluginDefinition 
     
    2423    # Signals for intertab communication plugin -> editor 
    2524    def __init__(self, parent=None, edit_only=False): 
    26         super(TabbedModelEditor, self).__init__(parent._parent) 
     25        super(TabbedModelEditor, self).__init__() 
    2726 
    2827        self.parent = parent 
     
    126125        self.editor_widget.setEnabled(True) 
    127126        self.editor_widget.blockSignals(False) 
    128         self.filename, _ = os.path.splitext(os.path.basename(filename)) 
    129  
    130         self.setWindowTitle(self.window_title + " - " + self.filename) 
     127        self.filename = filename 
     128        display_name, _ = os.path.splitext(os.path.basename(filename)) 
     129 
     130        self.setWindowTitle(self.window_title + " - " + display_name) 
    131131 
    132132    def onModifiedExit(self): 
     
    239239        # Run the model test in sasmodels 
    240240        try: 
    241             _ = GuiUtils.checkModel(full_path) 
     241            _ = self.checkModel(full_path) 
    242242        except Exception as ex: 
    243243            msg = "Error building model: "+ str(ex) 
     
    406406 
    407407    @classmethod 
     408    def checkModel(cls, path): 
     409        """ 
     410        Check that the model save in file 'path' can run. 
     411        """ 
     412        # try running the model 
     413        from sasmodels.sasview_model import load_custom_model 
     414        Model = load_custom_model(path) 
     415        model = Model() 
     416        q =  np.array([0.01, 0.1]) 
     417        _ = model.evalDistribution(q) 
     418        qx, qy =  np.array([0.01, 0.01]), np.array([0.1, 0.1]) 
     419        _ = model.evalDistribution([qx, qy]) 
     420 
     421        # check the model's unit tests run 
     422        from sasmodels.model_test import run_one 
     423        # TestSuite module in Qt5 now deletes tests in the suite after running, 
     424        # so suite[0] in run_one() in sasmodels/model_test.py will contain [None] and 
     425        # test.info.tests will raise. 
     426        # Not sure how to change the behaviour here, most likely sasmodels will have to 
     427        # be modified 
     428        result = run_one(path) 
     429 
     430        return result 
     431 
     432    @classmethod 
    408433    def getParamHelper(cls, param_str): 
    409434        """ 
Note: See TracChangeset for help on using the changeset viewer.