Changeset f80b8a9f in sasview


Ignore:
Timestamp:
Oct 11, 2016 9:03:53 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:
01cfd13
Parents:
46dfee9
Message:

Make sure the copy module is available regardless of how the model is loaded. Fixes #766

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    rec72ceb rf80b8a9f  
    2828import math 
    2929import re 
     30import logging 
    3031from wx.py.editwindow import EditWindow 
    3132from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     
    388389            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, 
    389390                                                         info=info)) 
    390         else: 
    391             raise 
    392391 
    393392    def on_help(self, event): 
     
    966965                        result, msg = None, "error building model" 
    967966                        check_err = "\n"+traceback.format_exc(limit=2) 
    968  
    969                     # Modified compiling test, as it will fail for sasmodels.sasview_model class 
    970                     # Should add a test to check that the class is correctly built  
    971                     # by sasview_model.make_class_from_file? 
    972 #                    try:  
    973 #                        tr_msg = _compile_file(self.fname) 
    974 #                        msg = str(tr_msg.__str__()) 
    975 #                        # Compile error 
    976 #                        if msg: 
    977 #                            msg.replace("  ", "\n") 
    978 #                            msg += "\nCompiling Failed" 
    979 #                            try: 
    980 #                                # try to remove pyc file if exists 
    981 #                                _delete_file(self.fname) 
    982 #                                _delete_file(self.fname + "c") 
    983 #                            except: 
    984 #                                pass 
    985 #                    except: 
    986 #                        pass 
    987967                else: 
    988968                    msg = "Error: The func(x) must 'return' a value at least.\n" 
     
    1002982                exec "from %s import Model" % name 
    1003983            except: 
    1004                 pass 
    1005 #            except: 
    1006 #                msg = 'new model fails to import in python' 
    1007 #                try: 
    1008 #                    # try to remove pyc file if exists 
    1009 #                    _delete_file(self.fname + "c") 
    1010 #                except: 
    1011 #                    pass 
    1012 # 
    1013 # And also need to test if model runs             
    1014 #        if self.base != None and not msg: 
    1015 #            try: 
    1016 #                Model().run(0.01) 
    1017 #            except: 
    1018 #                msg = "new model fails on run method:" 
    1019 #                _, value, _ = sys.exc_info() 
    1020 #                msg += "in %s:\n%s\n" % (name, value) 
    1021 #                try: 
    1022 #                    # try to remove pyc file if exists 
    1023 #                    _delete_file(self.fname + "c") 
    1024 #                except: 
    1025 #                    pass 
     984                logging.error(sys.exc_value) 
     985 
    1026986        # Prepare the messagebox 
    1027987        if msg: 
     
    12301190 
    12311191## Templates for custom models 
    1232 #CUSTOM_TEMPLATE = """ 
    1233 #from sas.models.pluginmodel import Model1DPlugin 
    1234 #from math import * 
    1235 #import os 
    1236 #import sys 
    1237 #import numpy 
    1238 ##import scipy? 
    1239 #class Model(Model1DPlugin): 
    1240 #    name = basename without extension of __file__ 
    1241 #    def __init__(self): 
    1242 #        Model1DPlugin.__init__(self, name=self.name) 
    1243 #        #set name same as file name 
    1244 #        #self.params here 
    1245 #        self.description = "%s" 
    1246 #        self.set_details() 
    1247 #    def function(self, x=0.0%s): 
    1248 #        #local params here 
    1249 #        #function here 
    1250 #""" 
    12511192 
    12521193CUSTOM_TEMPLATE = """ 
     
    14191360 
    14201361    def _clone(self, obj): 
     1362        import copy 
    14211363        obj.params     = copy.deepcopy(self.params) 
    14221364        obj.description     = copy.deepcopy(self.description) 
Note: See TracChangeset for help on using the changeset viewer.