Changeset ae08f14 in sasview for src/sas/sasgui


Ignore:
Timestamp:
Sep 27, 2016 10:30:51 AM (8 years ago)
Author:
smk78
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:
6c382da
Parents:
e925f61 (diff), a0373d5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://github.com/SasView/sasview

Location:
src/sas/sasgui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/utils.py

    rd85c194 ra0373d5  
    4646    return flag 
    4747 
    48      
     48 
     49def check_int(item): 
     50    """ 
     51    :param item: txtcrtl containing a value 
     52    """ 
     53    flag = True 
     54    try: 
     55        mini = int(item.GetValue()) 
     56        item.SetBackgroundColour(wx.WHITE) 
     57        item.Refresh() 
     58    except: 
     59        flag = False 
     60        item.SetBackgroundColour("pink") 
     61        item.Refresh() 
     62    return flag 
     63 
     64 
    4965class PanelMenu(wx.Menu): 
    5066    """ 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    ree4b3cb ra0373d5  
    1717from wx.lib.scrolledpanel import ScrolledPanel 
    1818 
    19 import sasmodels.sasview_model 
     19from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS 
     20 
    2021from sas.sasgui.guiframe.panel_base import PanelBase 
    21 from sas.sasgui.guiframe.utils import format_number, check_float, IdList 
     22from sas.sasgui.guiframe.utils import format_number, check_float, IdList, check_int 
    2223from sas.sasgui.guiframe.events import PanelOnFocusEvent 
    2324from sas.sasgui.guiframe.events import StatusEvent 
     
    626627        self.disp_help_bt.Bind(wx.EVT_BUTTON, self.on_pd_help_clicked, 
    627628                               id=self.disp_help_bt.GetId()) 
    628         self.disp_help_bt.SetToolTipString("Helps for Polydispersion.") 
     629        self.disp_help_bt.SetToolTipString("Help for polydispersion.") 
    629630 
    630631        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
     
    11231124                                                    state.disp_cb_dict[item]) 
    11241125                        # Create the dispersion objects 
    1125                         from sas.models.dispersion_models import ArrayDispersion 
    1126                         disp_model = ArrayDispersion() 
     1126                        disp_model = POLYDISPERSITY_MODELS['array']() 
    11271127                        if hasattr(state, "values") and \ 
    11281128                                 self.disp_cb_dict[item].GetValue() == True: 
     
    22812281                continue 
    22822282 
    2283             name = str(item[1]) 
    2284             if name.endswith(".npts") or name.endswith(".nsigmas"): 
     2283            value_ctrl = item[2] 
     2284            if not value_ctrl.IsEnabled(): 
     2285                # ArrayDispersion disables PD, Min, Max, Npts, Nsigs 
    22852286                continue 
    22862287 
    2287             # Check that min, max and value are floats 
    2288             value_ctrl, min_ctrl, max_ctrl = item[2], item[5], item[6] 
    2289             min_str = min_ctrl.GetValue().strip() 
    2290             max_str = max_ctrl.GetValue().strip() 
     2288            name = item[1] 
    22912289            value_str = value_ctrl.GetValue().strip() 
    2292             validity = check_float(value_ctrl) 
    2293             if min_str != "": 
    2294                 validity = validity and check_float(min_ctrl) 
    2295             if max_str != "": 
    2296                 validity = validity and check_float(max_ctrl) 
    2297             if not validity: 
    2298                 continue 
    2299  
    2300             # Check that min is less than max 
    2301             low = -numpy.inf if min_str == "" else float(min_str) 
    2302             high = numpy.inf if max_str == "" else float(max_str) 
    2303             if high < low: 
    2304                 min_ctrl.SetBackgroundColour("pink") 
    2305                 min_ctrl.Refresh() 
    2306                 max_ctrl.SetBackgroundColour("pink") 
    2307                 max_ctrl.Refresh() 
    2308                 #msg = "Invalid fit range for %s: min must be smaller than max"%name 
    2309                 #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    2310                 continue 
    2311  
    2312             # Force value between min and max 
    2313             value = float(value_str) 
    2314             if value < low: 
    2315                 value = low 
    2316                 value_ctrl.SetValue(format_number(value)) 
    2317             elif value > high: 
    2318                 value = high 
    2319                 value_ctrl.SetValue(format_number(value)) 
     2290            if name.endswith(".npts"): 
     2291                validity = check_int(value_ctrl) 
     2292                if not validity: 
     2293                    continue 
     2294                value = int(value_str) 
     2295 
     2296            elif name.endswith(".nsigmas"): 
     2297                validity = check_float(value_ctrl) 
     2298                if not validity: 
     2299                    continue 
     2300                value = float(value_str) 
     2301 
     2302            else:  # value or polydispersity 
     2303 
     2304                # Check that min, max and value are floats 
     2305                min_ctrl, max_ctrl = item[5], item[6] 
     2306                min_str = min_ctrl.GetValue().strip() 
     2307                max_str = max_ctrl.GetValue().strip() 
     2308                validity = check_float(value_ctrl) 
     2309                if min_str != "": 
     2310                    validity = validity and check_float(min_ctrl) 
     2311                if max_str != "": 
     2312                    validity = validity and check_float(max_ctrl) 
     2313                if not validity: 
     2314                    continue 
     2315 
     2316                # Check that min is less than max 
     2317                low = -numpy.inf if min_str == "" else float(min_str) 
     2318                high = numpy.inf if max_str == "" else float(max_str) 
     2319                if high < low: 
     2320                    min_ctrl.SetBackgroundColour("pink") 
     2321                    min_ctrl.Refresh() 
     2322                    max_ctrl.SetBackgroundColour("pink") 
     2323                    max_ctrl.Refresh() 
     2324                    #msg = "Invalid fit range for %s: min must be smaller than max"%name 
     2325                    #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     2326                    continue 
     2327 
     2328                # Force value between min and max 
     2329                value = float(value_str) 
     2330                if value < low: 
     2331                    value = low 
     2332                    value_ctrl.SetValue(format_number(value)) 
     2333                elif value > high: 
     2334                    value = high 
     2335                    value_ctrl.SetValue(format_number(value)) 
     2336 
     2337                if name not in self.model.details.keys(): 
     2338                    self.model.details[name] = ["", None, None] 
     2339                old_low, old_high = self.model.details[name][1:3] 
     2340                if old_low != low or old_high != high: 
     2341                    # The configuration has changed but it won't change the 
     2342                    # computed curve so no need to set is_modified to True 
     2343                    #is_modified = True 
     2344                    self.model.details[name][1:3] = low, high 
    23202345 
    23212346            # Update value in model if it has changed 
     
    23232348                self.model.setParam(name, value) 
    23242349                is_modified = True 
    2325  
    2326             if name not in self.model.details.keys(): 
    2327                 self.model.details[name] = ["", None, None] 
    2328             old_low, old_high = self.model.details[name][1:3] 
    2329             if old_low != low or old_high != high: 
    2330                 # The configuration has changed but it won't change the 
    2331                 # computed curve so no need to set is_modified to True 
    2332                 #is_modified = True 
    2333                 self.model.details[name][1:3] = low, high 
    23342350 
    23352351        return is_modified 
     
    26872703        :param disp_function: dispersion distr. function 
    26882704        """ 
    2689         # List of the poly_model name in the combobox 
    2690         list = ["RectangleDispersion", "ArrayDispersion", 
    2691                 "LogNormalDispersion", "GaussianDispersion", 
    2692                 "SchulzDispersion"] 
    2693  
    26942705        # Find the selection 
    2695         try: 
    2696             selection = list.index(disp_func.__class__.__name__) 
    2697             return selection 
    2698         except: 
    2699             return 3 
     2706        if disp_func is not None: 
     2707            try: 
     2708                return POLYDISPERSITY_MODELS.values().index(disp_func.__class__) 
     2709            except ValueError: 
     2710                pass  # Fall through to default class 
     2711        return POLYDISPERSITY_MODELS.keys().index('gaussian') 
    27002712 
    27012713    def on_reset_clicked(self, event): 
  • src/sas/sasgui/perspectives/fitting/media/plugin.rst

    r31d7803 re925f61  
    660660^^^^^^^^^^^^^^^^^^^ 
    661661 
     662Installed SasView 
     663................. 
     664 
    662665If you are editing your model from the SasView GUI, you can test it 
    663666by selecting *Run > Compile* from the *Model Editor* menu bar. An 
    664667*Info* box will appear with the results of the compilation and a 
    665668check that the model runs. 
     669 
     670 
     671Built SasView 
     672............. 
    666673 
    667674If the model compiles and runs, you can next run the unit tests that 
     
    721728 
    722729 
    723 Clean Lint 
    724 ^^^^^^^^^^ 
    725  
    726 **NB: For now we are not providing pylint with SasView; so unless you have a 
    727 SasView development environment available, you can ignore this section!** 
     730Clean Lint - (Developer Version Only) 
     731^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
     732 
     733**NB: For now we are not providing pylint with the installer version of SasView;  
     734so unless you have a SasView build environment available, you can ignore this section!** 
    728735 
    729736Run the lint check with:: 
     
    758765Don't put in too many pylint statements, though, since they make the code ugly. 
    759766 
    760 Check The Docs 
    761 ^^^^^^^^^^^^^^ 
     767Check The Docs - (Developer Version Only) 
     768^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
    762769 
    763770You can get a rough idea of how the documentation will look using the 
     
    778785There is also a neat online WYSIWYG ReStructuredText editor at http://rst.ninjs.org\ . 
    779786 
    780 Finally 
    781 ^^^^^^^ 
     787Share Your Model! 
     788^^^^^^^^^^^^^^^^^ 
    782789 
    783790Once compare and the unit test(s) pass properly and everything is done, 
    784791consider adding your model to the 
    785 `Model Marketplace <http://marketplace.sasview.org/>`_. 
     792`Model Marketplace <http://marketplace.sasview.org/>`_ so that others may use it! 
Note: See TracChangeset for help on using the changeset viewer.