Changeset 0008f54 in sasview for calculatorview/src/sans


Ignore:
Timestamp:
Jun 14, 2012 4:22:57 PM (12 years ago)
Author:
Jae Cho <jhjcho@…>
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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
fdef956
Parents:
72538fc
Message:

trying to fix test problem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/src/sans/perspectives/calculator/model_editor.py

    r316e231 r0008f54  
    5959    def __init__(self, parent=None, base=None, id=None, title='', model_list=[], plugin_dir=None): 
    6060        """ 
    61         Dialog window popup when selecting 'Easy Custom Sum' on the menu 
     61        Dialog window popup when selecting 'Easy Custom Sum/Multiply' on the menu 
    6262        """ 
    6363        wx.Dialog.__init__(self, parent=parent, id=id,  
     
    7575        self.model2_string = "CylinderModel" 
    7676        self._notes = '' 
     77        self.operator = '+' 
    7778        self._msg_box = None 
    7879        self.msg_sizer = None 
     
    8990        self.name_hsizer = wx.BoxSizer(wx.HORIZONTAL) 
    9091        #title name [string] 
    91         name_txt = wx.StaticText(self, -1, 'SumFunction Name : ')   
     92        name_txt = wx.StaticText(self, -1, 'Function Name : ')   
    9293        self.name_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1))  
    9394        self.name_tcl.Bind(wx.EVT_TEXT_ENTER, self.on_change_name) 
    9495        self.name_tcl.SetValue('') 
    9596        self.name_tcl.SetFont(self.font) 
    96         hint_name = "Unique Sum Model Function Name." 
     97        hint_name = "Unique Sum/Multiply Model Function Name." 
    9798        self.name_tcl.SetToolTipString(hint_name) 
    9899        self.name_hsizer.AddMany([(name_txt, 0, wx.LEFT|wx.TOP, 10), 
     
    152153                                     size=(_BOX_WIDTH/2, 25)) 
    153154        # Intro 
    154         explanation  = "  custom model = scale_factor * (model1 + model2)\n" 
     155        explanation  = "  custom model = scale_factor * (model1 %s model2)\n"\ 
     156                            % self.operator 
    155157        #explanation  += "  Note: This will overwrite the previous sum model.\n" 
    156158        model_string = " Model%s (p%s):" 
     
    231233        if len(title) > 20: 
    232234            s_title = title[0:19] + '...' 
    233         self._notes = "SumModel function (%s) has been set! \n" % str(s_title) 
     235        self._notes = "Model function (%s) has been set! \n" % str(s_title) 
    234236        self.good_name = True 
    235237        self.on_apply(self.fname) 
     
    249251            self.parent.update_custom_combo() 
    250252            msg = self._notes 
    251             info = 'Infor' 
     253            info = 'Info' 
    252254            color = 'blue' 
    253255        except: 
     
    307309        description = self.desc_tcl.GetValue().lstrip().rstrip() 
    308310        if description == '': 
    309             description = name1 + "+" + name2 
     311            description = name1 + self.operator + name2 
    310312        name = self.name_tcl.GetValue().lstrip().rstrip() 
    311313        if name == '': 
     
    324326            elif line.count("self.description = '%s'"): 
    325327                out_f.write(line % description + "\n") 
    326             #elif line.count("self.name = '%s'"): 
    327             #    out_f.write(line % name + "\n") 
     328            elif line.count("run") and line.count("%s"): 
     329                out_f.write(line % self.operator) 
     330            elif line.count("evalDistribution") and line.count("%s"): 
     331                out_f.write(line % self.operator) 
    328332            else: 
    329333                out_f.write(line + "\n") 
     
    854858""" 
    855859SUM_TEMPLATE = """ 
    856 # A sample of an experimental model function for Sum(Pmodel1,Pmodel2) 
     860# A sample of an experimental model function for Sum/Multiply(Pmodel1,Pmodel2) 
    857861import copy 
    858862from sans.models.pluginmodel import Model1DPlugin 
     
    951955            p1_name = name1 
    952956        name = p1_name 
    953         name += "+" 
     957        name += "%s"% (self.operator) 
    954958        p2_name = self._get_upper_name(name2) 
    955959        if not p2_name: 
     
    10241028                 
    10251029    def setParam(self, name, value): 
    1026         # set param to p1+p2 model 
     1030        # set param to this (p1, p2) model 
    10271031        self._setParamHelper(name, value) 
    10281032         
     
    10931097        self._set_scale_factor() 
    10941098        return self.params['scale_factor'] * \ 
    1095 (self.p_model1.run(x) + self.p_model2.run(x)) 
     1099(self.p_model1.run(x) %s self.p_model2.run(x)) 
    10961100     
    10971101    def runXY(self, x = 0.0): 
    10981102        self._set_scale_factor() 
    10991103        return self.params['scale_factor'] * \ 
    1100 (self.p_model1.runXY(x) + self.p_model2.runXY(x)) 
     1104(self.p_model1.runXY(x) %s self.p_model2.runXY(x)) 
    11011105     
    11021106    ## Now (May27,10) directly uses the model eval function  
     
    11051109        self._set_scale_factor() 
    11061110        return self.params['scale_factor'] * \ 
    1107 (self.p_model1.evalDistribution(x) + \ 
     1111(self.p_model1.evalDistribution(x) %s \ 
    11081112self.p_model2.evalDistribution(x)) 
    11091113 
     
    11261130    def fill_description(self, p_model1, p_model2): 
    11271131        description = "" 
    1128         description +="This model gives the summation of  %s and %s. "% \ 
    1129 ( p_model1.name, p_model2.name ) 
     1132        description += "This model gives the summation or multiplication of" 
     1133        description += "%s and %s. "% ( p_model1.name, p_model2.name ) 
    11301134        self.description += description 
    11311135           
     
    11491153    #m2.p_model2.setParam("scale", 100) 
    11501154    #m2.p_model2.setParam("rg", 100) 
    1151     out2 = m2.p_model1.runXY(0.01) + m2.p_model2.runXY(0.01) 
     1155    out2 = m2.p_model1.runXY(0.01) %s m2.p_model2.runXY(0.01)\n 
    11521156    print out1, " = ", out2 
    11531157    if out1 == out2: 
Note: See TracChangeset for help on using the changeset viewer.