Changeset 6d2b50b in sasview for src


Ignore:
Timestamp:
Feb 7, 2017 11:05:25 AM (8 years ago)
Author:
krzywon
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:
5e6df0e
Parents:
eb2dc13
Message:

Change the elif block to a dictionary search to minimize the number of checks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    r18b7ca96 r6d2b50b  
    367367        """ 
    368368        if self.formfactorcombobox == '': 
    369             if self.categorycombobox == '' and len(self.parameters) == 3: 
    370                 self.categorycombobox = "Shape-Independent" 
    371                 self.formfactorcombobox = 'PowerLawAbsModel' 
    372             elif self.categorycombobox == '' and len(self.parameters) == 9: 
    373                 self.categorycombobox = 'Cylinder' 
    374                 self.formfactorcombobox = 'barbell' 
    375             elif self.categorycombobox == 'Shapes': 
    376                 self.formfactorcombobox = 'BCCrystalModel' 
    377             elif self.categorycombobox == 'Uncategorized': 
    378                 self.formfactorcombobox = 'LineModel' 
    379             elif self.categorycombobox == 'StructureFactor': 
    380                 self.structurecombobox = 'HardsphereStructure' 
    381             elif self.categorycombobox == 'Customized Models': 
    382                 self.formfactorcombobox = 'MySumFunction' 
    383             elif self.categorycombobox == 'Ellipsoid': 
    384                 self.formfactorcombobox = 'core_shell_ellipsoid' 
    385             elif self.categorycombobox == 'Lamellae': 
    386                 self.formfactorcombobox = 'lamellar' 
    387             elif self.categorycombobox == 'Paracrystal': 
    388                 self.formfactorcombobox = 'bcc_paracrystal' 
    389             elif self.categorycombobox == 'Parallelepiped': 
    390                 self.formfactorcombobox = 'core_shell_parallelepiped' 
    391             elif self.categorycombobox == 'Shape Independent': 
    392                 self.formfactorcombobox = 'be_polyelectrolyte' 
    393             elif self.categorycombobox == 'Sphere': 
    394                 self.formfactorcombobox = 'adsorbed_layer' 
    395             elif self.categorycombobox == 'Structure Factor': 
    396                 self.formfactorcombobox = 'hardsphere' 
     369            FIRST_FORM = { 
     370                'Shapes' : 'BCCrystalModel', 
     371                'Uncategorized' : 'LineModel', 
     372                'StructureFactor' : 'HardsphereStructure', 
     373                'Ellipsoid' : 'core_shell_ellipsoid', 
     374                'Lamellae' : 'lamellar', 
     375                'Paracrystal' : 'bcc_paracrystal', 
     376                'Parallelepiped' : 'core_shell_parallelepiped', 
     377                'Shape Independent' : 'be_polyelectrolyte', 
     378                'Sphere' : 'adsorbed_layer', 
     379                'Structure Factor' : 'hardsphere', 
     380                'Customized Models' : '' 
     381            } 
     382            if self.categorycombobox == '': 
     383                if len(self.parameters) == 3: 
     384                    self.categorycombobox = "Shape-Independent" 
     385                    self.formfactorcombobox = 'PowerLawAbsModel' 
     386                elif len(self.parameters) == 9: 
     387                    self.categorycombobox = 'Cylinder' 
     388                    self.formfactorcombobox = 'barbell' 
     389                else: 
     390                    msg = "Save state does not have enough information to load" 
     391                    msg += " the all of the data." 
     392                    logging.warning(msg=msg) 
     393            else: 
     394                self.formfactorcombobox = FIRST_FORM[self.categorycombobox] 
    397395 
    398396    @staticmethod 
Note: See TracChangeset for help on using the changeset viewer.