Changeset 5501189 in sasview for src


Ignore:
Timestamp:
Apr 2, 2018 2:34:54 AM (6 years ago)
Author:
gonzalezm
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
Children:
d247504b
Parents:
943e17a
Message:

Simple editor without PD parameters

File:
1 edited

Legend:

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

    r2469df7 r5501189  
    660660        Do the layout for parameter related widgets 
    661661        """ 
    662         param_txt = wx.StaticText(self, -1, 'Fit Parameters NOT requiring' + \ 
    663                                   ' polydispersity (if any): ') 
    664  
    665         param_tip = "#Set the parameters NOT requiring polydispersity " + \ 
    666         "and their initial values.\n" 
     662        param_txt = wx.StaticText(self, -1, 'Fit Parameters: ') 
     663 
     664        param_tip = "#Set the parameters and their initial values.\n" 
    667665        param_tip += "#Example:\n" 
    668666        param_tip += "A = 1\nB = 1" 
     
    678676                                  (self.param_tcl, 1, wx.EXPAND | wx.ALL, 10)]) 
    679677 
    680         # Parameters with polydispersity 
    681         pd_param_txt = wx.StaticText(self, -1, 'Fit Parameters requiring ' + \ 
    682                                      'polydispersity (if any): ') 
    683  
    684         pd_param_tip = "#Set the parameters requiring polydispersity and " + \ 
    685         "their initial values.\n" 
    686         pd_param_tip += "#Example:\n" 
    687         pd_param_tip += "C = 2\nD = 2" 
    688         newid = wx.NewId() 
    689         self.pd_param_tcl = EditWindow(self, newid, wx.DefaultPosition, 
    690                                     wx.DefaultSize, 
    691                                     wx.CLIP_CHILDREN | wx.SUNKEN_BORDER) 
    692         self.pd_param_tcl.setDisplayLineNumbers(True) 
    693         self.pd_param_tcl.SetToolTipString(pd_param_tip) 
    694  
    695         self.param_sizer.AddMany([(pd_param_txt, 0, wx.LEFT, 10), 
    696                                   (self.pd_param_tcl, 1, wx.EXPAND | wx.ALL, 10)]) 
    697678 
    698679    def _layout_function(self): 
     
    896877            description = self.desc_tcl.GetValue() 
    897878            param_str = self.param_tcl.GetText() 
    898             pd_param_str = self.pd_param_tcl.GetText() 
    899879            func_str = self.function_tcl.GetText() 
    900880            # No input for the model function 
     
    902882                if func_str.count('return') > 0: 
    903883                    self.write_file(self.fname, name, description, param_str, 
    904                                     pd_param_str, func_str) 
     884                                    func_str) 
    905885                    try: 
    906886                        result, msg = check_model(self.fname), None 
     
    942922        self.warning = msg 
    943923 
    944     def write_file(self, fname, name, desc_str, param_str, pd_param_str, func_str): 
     924    def write_file(self, fname, name, desc_str, param_str, func_str): 
    945925        """ 
    946926        Write content in file 
     
    949929        :param desc_str: content of the description strings 
    950930        :param param_str: content of params; Strings 
    951         :param pd_param_str: content of params requiring polydispersity; Strings 
    952931        :param func_str: content of func; Strings 
    953932        """ 
     
    963942        # Write out parameters 
    964943        param_names = []    # to store parameter names 
    965         pd_params = [] 
    966944        out_f.write('parameters = [ \n') 
    967945        out_f.write('#   ["name", "units", default, [lower, upper], "type", "description"],\n') 
     
    970948            out_f.write("    ['%s', '', %s, [-inf, inf], '', '%s'],\n" 
    971949                        % (pname, pvalue, desc)) 
    972         for pname, pvalue, desc in self.get_param_helper(pd_param_str): 
    973             param_names.append(pname) 
    974             pd_params.append(pname) 
    975             out_f.write("    ['%s', '', %s, [-inf, inf], 'volume', '%s'],\n" 
    976                         % (pname, pvalue, desc)) 
    977950        out_f.write('    ]\n') 
    978951 
    979952        # Write out function definition 
     953        out_f.write('\n') 
    980954        out_f.write('def Iq(%s):\n' % ', '.join(['x'] + param_names)) 
    981955        out_f.write('    """Absolute scattering"""\n') 
     
    987961            out_f.write('    import numpy as np') 
    988962        for func_line in func_str.split('\n'): 
    989             out_f.write('%s%s\n' % (spaces4, func_line)) 
     963            out_f.write('%s%s\n' % ('    ', func_line)) 
    990964        out_f.write('## uncomment the following if Iq works for vector x\n') 
    991965        out_f.write('#Iq.vectorized = True\n') 
    992  
    993         # If polydisperse, create place holders for form_volume, ER and VR 
    994         if pd_params: 
    995             out_f.write('\n') 
    996             out_f.write(CUSTOM_TEMPLATE_PD % {'args': ', '.join(pd_params)}) 
    997966 
    998967        # Create place holder for Iqxy 
     
    11331102    and to weight polydisperse parameter contributions. 
    11341103    """ 
    1135     return 0.0 
     1104    return 1.0 
    11361105 
    11371106def ER(%(args)s): 
Note: See TracChangeset for help on using the changeset viewer.