Changeset 1b061a31 in sasview


Ignore:
Timestamp:
Jan 13, 2017 1:58:07 AM (7 years ago)
Author:
wojciech
Children:
506bca3
Parents:
65d1d04
git-author:
wpotrzebowski <Wojciech.Potrzebowski@…> (01/13/17 01:56:27)
git-committer:
wpotrzebowski <Wojciech.Potrzebowski@…> (01/13/17 01:58:07)
Message:

Changes to code after code review by PR

Location:
src/sas/sasgui
Files:
3 edited

Legend:

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

    re2c0939 r1b061a31  
    21162116 
    21172117    def _write_opencl_config_file(self): 
    2118         #from sas.sasgui.guiframe.customdir import SetupCustom 
    2119         #from sas.sasgui.guiframe.gui_manager import _find_local_config 
    2120  
    2121         sas_opencl = os.environ.get("SAS_OPENCL",None) 
    2122         #How to store it in file 
    2123         new_config_lines = [] 
    2124         config_file = open(custom_config.__file__) 
     2118        """ 
     2119        Writes OpenCL settings to custom config file, so they can be remmbered 
     2120        from session to session 
     2121        """ 
    21252122        if custom_config is not None: 
     2123            sas_opencl = os.environ.get("SAS_OPENCL",None) 
     2124            new_config_lines = [] 
     2125            config_file = open(custom_config.__file__) 
    21262126            config_lines = config_file.readlines() 
    21272127            for line in config_lines: 
     
    21332133                else: 
    21342134                    new_config_lines.append(line) 
    2135         config_file.close() 
    2136         new_config_file = open(custom_config.__file__,"w") 
    2137         new_config_file.writelines(new_config_lines) 
    2138         new_config_file.close() 
     2135            config_file.close() 
     2136 
     2137            #If custom_config is None, settings will not be remmbered 
     2138            new_config_file = open(custom_config.__file__,"w") 
     2139            new_config_file.writelines(new_config_lines) 
     2140            new_config_file.close() 
     2141        else: 
     2142            logging.info("Failed to save OPENCL settings in custom config file") 
    21392143 
    21402144 
  • src/sas/sasgui/guiframe/startup_configuration.py

    r2a1b92eb r1b061a31  
    4646                       'CLEANUP_PLOT':CURRENT.CLEANUP_PLOT, 
    4747                       'DEFAULT_PERSPECTIVE':CURRENT.DEFAULT_PERSPECTIVE, 
    48                        'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDE, 
     48                       'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDER, 
    4949                       'SAS_OPENCL': None} 
    5050except: 
  • src/sas/sasgui/perspectives/fitting/gpu_options.py

    r65d1d04 r1b061a31  
    1212import warnings 
    1313import wx 
     14import sasmodels 
    1415from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
    1516 
     
    164165        """ 
    165166        clinfo = [] 
     167        platforms = [] 
    166168        try: 
    167169            import pyopencl as cl 
    168170            platforms = cl.get_platforms() 
    169             p_index = 0 
    170             for platform in platforms: 
    171                 d_index = 0 
    172                 devices = platform.get_devices() 
    173                 for device in devices: 
    174                     if len(devices) > 1 and len(platforms) > 1: 
    175                         combined_index = ":".join([str(p_index), str(d_index)]) 
    176                     elif len(platforms) > 1: 
    177                         combined_index = str(p_index) 
    178                     else: 
    179                         combined_index = str(d_index) 
    180                     clinfo.append((combined_index, ":".join([platform.name, device.name]))) 
    181                     d_index += 1 
    182                 p_index += 1 
    183171        except ImportError: 
    184172            warnings.warn("pyopencl import failed. Using only CPU computations") 
     173 
     174        p_index = 0 
     175        for platform in platforms: 
     176            d_index = 0 
     177            devices = platform.get_devices() 
     178            for device in devices: 
     179                if len(devices) > 1 and len(platforms) > 1: 
     180                    combined_index = ":".join([str(p_index), str(d_index)]) 
     181                elif len(platforms) > 1: 
     182                    combined_index = str(p_index) 
     183                else: 
     184                    combined_index = str(d_index) 
     185                clinfo.append((combined_index, ":".join([platform.name, device.name]))) 
     186                d_index += 1 
     187            p_index += 1 
    185188 
    186189        clinfo.append(("None", "No OpenCL")) 
     
    206209        Close window on accpetance 
    207210        """ 
    208         import sasmodels 
     211 
    209212        #If statement added to handle Reset 
    210213        if self.sas_opencl: 
     
    223226    def on_reset(self, event): 
    224227        """ 
    225         Close window on accpetance 
     228        Resets selected values 
    226229        """ 
    227230        for btn in self.buttons: 
     
    236239        import json 
    237240        import platform 
    238         import sasmodels 
     241        #import sasmodels 
    239242 
    240243        #The same block of code as for OK but it is needed if we want to have 
Note: See TracChangeset for help on using the changeset viewer.