Changes in / [d96744de:dcd6efd] in sasview


Ignore:
Location:
src/sas
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/sas/_config.py

    rb963b20 r93b34cc  
    8686def setup_custom_config(app_dir, user_dir): 
    8787    path = make_custom_config_path(user_dir) 
     88    #logger.info("custom config path %s", path) 
    8889    if not os.path.isfile(path): 
    8990        try: 
     
    9495            logger.error("Could not copy default custom config.") 
    9596 
     97    custom_config = load_custom_config(path) 
     98 
    9699    #Adding SAS_OPENCL if it doesn't exist in the config file 
    97100    # - to support backcompability 
    98     if not "SAS_OPENCL" in open(path).read(): 
     101    if not hasattr(custom_config, "SAS_OPENCL"): 
     102        custom_config.SAS_OPENCL = None 
    99103        try: 
    100             open(config_file, "a+").write("SAS_OPENCL = \"None\"\n") 
     104            open(path, "a+").write("SAS_OPENCL = \"None\"\n") 
    101105        except Exception: 
    102106            logger.error("Could not update custom config with SAS_OPENCL.") 
    103107 
    104     custom_config = load_custom_config(path) 
    105108    return custom_config 
    106  
    107109 
    108110def load_custom_config(path): 
  • src/sas/sasgui/guiframe/gui_manager.py

    r9220e89c r9220e89c  
    6363SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 
    6464SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 
    65 if not WELCOME_PANEL_ON: 
    66     WELCOME_PANEL_SHOW = False 
     65 
     66def custom_value(name, default=None): 
     67    """ 
     68    Fetch a config value from custom_config.  Fallback to config, and then 
     69    to default if it doesn't exist in config. 
     70    """ 
     71    default = getattr(config, name, default) 
     72    return getattr(custom_config, name, default) 
     73 
     74# Custom config values in the order they appear. 
     75DATAPANEL_WIDTH = custom_value('DATAPANEL_WIDTH', -1) 
     76CLEANUP_PLOT = custom_value('CLEANUP_PLOT', False) 
     77FIXED_PANEL = custom_value('FIXED_PANEL', True) 
     78PLOPANEL_WIDTH = custom_value('PLOPANEL_WIDTH', -1) 
     79DATALOADER_SHOW = custom_value('DATALOADER_SHOW', True) 
     80GUIFRAME_HEIGHT = custom_value('GUIFRAME_HEIGHT', -1) 
     81GUIFRAME_WIDTH = custom_value('GUIFRAME_WIDTH', -1) 
     82CONTROL_WIDTH = custom_value('CONTROL_WIDTH', -1) 
     83CONTROL_HEIGHT = custom_value('CONTROL_HEIGHT', -1) 
     84open_folder = custom_value('DEFAULT_OPEN_FOLDER', None) 
     85if open_folder is not None and os.path.isdir(open_folder): 
     86    DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
    6787else: 
    68     WELCOME_PANEL_SHOW = True 
    69 try: 
    70     DATALOADER_SHOW = custom_config.DATALOADER_SHOW 
    71     TOOLBAR_SHOW = custom_config.TOOLBAR_SHOW 
    72     FIXED_PANEL = custom_config.FIXED_PANEL 
    73     if WELCOME_PANEL_ON: 
    74         WELCOME_PANEL_SHOW = custom_config.WELCOME_PANEL_SHOW 
    75     PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH 
    76     DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH 
    77     GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH 
    78     GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT 
    79     CONTROL_WIDTH = custom_config.CONTROL_WIDTH 
    80     CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT 
    81     DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE 
    82     CLEANUP_PLOT = custom_config.CLEANUP_PLOT 
    83     # custom open_path 
    84     open_folder = custom_config.DEFAULT_OPEN_FOLDER 
    85     if open_folder is not None and os.path.isdir(open_folder): 
    86         DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
    87     else: 
    88         DEFAULT_OPEN_FOLDER = get_app_dir() 
    89     SAS_OPENCL = custom_config.SAS_OPENCL 
    90 except: 
    91     DATALOADER_SHOW = True 
    92     TOOLBAR_SHOW = True 
    93     FIXED_PANEL = True 
    94     WELCOME_PANEL_SHOW = False 
    95     PLOPANEL_WIDTH = config.PLOPANEL_WIDTH 
    96     DATAPANEL_WIDTH = config.DATAPANEL_WIDTH 
    97     GUIFRAME_WIDTH = config.GUIFRAME_WIDTH 
    98     GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT 
    99     CONTROL_WIDTH = -1 
    100     CONTROL_HEIGHT = -1 
    101     DEFAULT_PERSPECTIVE = None 
    102     CLEANUP_PLOT = False 
    10388    DEFAULT_OPEN_FOLDER = get_app_dir() 
    104     DEFAULT_OPEN_FOLDER = PATH_APP 
    105     SAS_OPENCL = None 
     89WELCOME_PANEL_SHOW = (custom_value('WELCOME_PANEL_SHOW', False) 
     90                      if WELCOME_PANEL_ON else False) 
     91TOOLBAR_SHOW = custom_value('TOOLBAR_SHOW', True) 
     92DEFAULT_PERSPECTIVE = custom_value('DEFAULT_PERSPECTIVE', 'Fitting') 
     93SAS_OPENCL = custom_value('SAS_OPENCL', 'None') 
     94 
    10695DEFAULT_STYLE = config.DEFAULT_STYLE 
    107  
    10896PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS 
    10997OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU 
     
    21712159        # original 2.x tutorial. 
    21722160        # Code below, implemented from 4.2.0, redirects 
    2173         # action to the Tutorials page of the help  
     2161        # action to the Tutorials page of the help 
    21742162        # documentation to give access to all available 
    21752163        # tutorials 
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    r9bf40e7 r1752f38  
    965965        out_f.write('    """Absolute scattering"""\n') 
    966966        if "scipy." in func_str: 
    967             out_f.write('    import scipy') 
     967            out_f.write('    import scipy\n') 
    968968        if "numpy." in func_str: 
    969             out_f.write('    import numpy') 
     969            out_f.write('    import numpy\n') 
    970970        if "np." in func_str: 
    971             out_f.write('    import numpy as np') 
     971            out_f.write('    import numpy as np\n') 
    972972        for func_line in func_str.split('\n'): 
    973973            out_f.write('%s%s\n' % ('    ', func_line)) 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    raba4559 ra5cffe5  
    776776        :param weight: current dy data 
    777777        """ 
    778         # If we are not dealing with a specific fit problem, then 
    779         # there is no point setting the weights. 
    780         if fid is None: 
    781             return 
     778        # Note: this is used to set the data weights for the fit based on 
     779        # the weight selection in the GUI. 
    782780        if uid in self.page_finder.keys(): 
    783781            self.page_finder[uid].set_weight(flag=flag, is2d=is2d) 
  • src/sas/sasgui/perspectives/fitting/gpu_options.py

    r8e109f9 r895703d  
    2323import sasmodels 
    2424import sasmodels.model_test 
    25 import sasmodels.kernelcl 
     25import sasmodels.sasview_model 
    2626 
    2727from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     
    239239            if "SAS_OPENCL" in os.environ: 
    240240                del os.environ["SAS_OPENCL"] 
    241         sasmodels.kernelcl.reset_environment() 
     241        sasmodels.sasview_model.reset_environment() 
    242242        event.Skip() 
    243243 
     
    265265            if "SAS_OPENCL" in os.environ: 
    266266                del os.environ["SAS_OPENCL"] 
    267         sasmodels.kernelcl.reset_environment() 
     267        sasmodels.sasview_model.reset_environment() 
    268268 
    269269        try: 
Note: See TracChangeset for help on using the changeset viewer.