Changeset 81b1f4d in sasview for src/sas/sasgui/perspectives/fitting


Ignore:
Timestamp:
May 16, 2017 6:19:57 AM (7 years ago)
Author:
GitHub <noreply@…>
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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
fca1f50, 7132e49
Parents:
2f17d40 (diff), 56a282c (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.
git-author:
Adam Washington <rprospero@…> (05/16/17 06:19:57)
git-committer:
GitHub <noreply@…> (05/16/17 06:19:57)
Message:

Merge pull request #85 from rprospero/findModels_tidy

Tidy up the _findModels function

The function underwent the following simple improvements

a) renamed to the more pythonic _find_models
b) had an unused parameter removed
c) eliminated shadowing of builtin dir function
d) passed pep8 standards

Location:
src/sas/sasgui/perspectives/fitting
Files:
4 edited

Legend:

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

    ra1b8fee r81b1f4d  
    163163 
    164164 
    165 def _findModels(dir): 
     165def _find_models(): 
    166166    """ 
    167167    Find custom models 
    168168    """ 
    169169    # List of plugin objects 
    170     dir = find_plugins_dir() 
     170    directory = find_plugins_dir() 
    171171    # Go through files in plug-in directory 
    172     if not os.path.isdir(dir): 
    173         msg = "SasView couldn't locate Model plugin folder %r." % dir 
     172    if not os.path.isdir(directory): 
     173        msg = "SasView couldn't locate Model plugin folder %r." % directory 
    174174        logger.warning(msg) 
    175175        return {} 
    176176 
    177     plugin_log("looking for models in: %s" % str(dir)) 
    178     #compile_file(dir)  #always recompile the folder plugin 
    179     logger.info("plugin model dir: %s" % str(dir)) 
     177    plugin_log("looking for models in: %s" % str(directory)) 
     178    # compile_file(directory)  #always recompile the folder plugin 
     179    logger.info("plugin model dir: %s" % str(directory)) 
    180180 
    181181    plugins = {} 
    182     for filename in os.listdir(dir): 
     182    for filename in os.listdir(directory): 
    183183        name, ext = os.path.splitext(filename) 
    184184        if ext == '.py' and not name == '__init__': 
    185             path = os.path.abspath(os.path.join(dir, filename)) 
     185            path = os.path.abspath(os.path.join(directory, filename)) 
    186186            try: 
    187187                model = load_custom_model(path) 
     
    193193                plugin_log(msg) 
    194194                logger.warning("Failed to load plugin %r. See %s for details" 
    195                                 % (path, PLUGIN_LOG)) 
    196              
     195                               % (path, PLUGIN_LOG)) 
     196 
    197197    return plugins 
    198198 
     
    264264        temp = {} 
    265265        if self.is_changed(): 
    266             return  _findModels(dir) 
     266            return  _find_models() 
    267267        logger.info("plugin model : %s" % str(temp)) 
    268268        return temp 
     
    339339        """ 
    340340        self.plugins = [] 
    341         new_plugins = _findModels(dir) 
     341        new_plugins = _find_models() 
    342342        for name, plug in  new_plugins.iteritems(): 
    343343            for stored_name, stored_plug in self.stored_plugins.iteritems(): 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r9c0f3c17 ra1b8fee  
    22Base Page for fitting 
    33""" 
     4from __future__ import print_function 
     5 
    46import sys 
    57import os 
     
    657659        # It seems MAC needs wxCallAfter 
    658660        if event.GetId() == GUIFRAME_ID.COPYEX_ID: 
    659             print "copy excel" 
     661            print("copy excel") 
    660662            wx.CallAfter(self.get_copy_excel) 
    661663        elif event.GetId() == GUIFRAME_ID.COPYLAT_ID: 
    662             print "copy latex" 
     664            print("copy latex") 
    663665            wx.CallAfter(self.get_copy_latex) 
    664666        else: 
     
    33683370        except Exception: 
    33693371            logger.error(traceback.format_exc()) 
    3370             print "Error in BasePage._paste_poly_help: %s" % \ 
    3371                   sys.exc_info()[1] 
     3372            print("Error in BasePage._paste_poly_help: %s" % \ 
     3373                  sys.exc_info()[1]) 
    33723374 
    33733375    def _set_disp_cb(self, isarray, item): 
     
    33983400            Moveit; This method doesn't belong here 
    33993401        """ 
    3400         print "BasicPage.update_pinhole_smear was called: skipping" 
     3402        print("BasicPage.update_pinhole_smear was called: skipping") 
    34013403        return 
    34023404 
     
    35743576        # check model type to show sizer 
    35753577        if self.model is not None: 
    3576             print "_set_model_sizer_selection: disabled." 
     3578            print("_set_model_sizer_selection: disabled.") 
    35773579            # self._set_model_sizer_selection(self.model) 
    35783580 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r7432acb ra1b8fee  
    1111#copyright 2009, University of Tennessee 
    1212################################################################################ 
     13from __future__ import print_function 
     14 
    1315import re 
    1416import sys 
     
    12531255        """ 
    12541256        """ 
    1255         print "update_fit result", result 
     1257        print("update_fit result", result) 
    12561258 
    12571259    def _batch_fit_complete(self, result, pars, page_id, 
     
    20462048            res = (fn - gn) / en 
    20472049        except ValueError: 
    2048             print "Unmatch lengths %s, %s, %s" % (len(fn), len(gn), len(en)) 
     2050            print("Unmatch lengths %s, %s, %s" % (len(fn), len(gn), len(en))) 
    20492051            return 
    20502052 
  • src/sas/sasgui/perspectives/fitting/media/plugin.rst

    r984f3fc r72100ee  
    538538    sin, cos, tan, asin, acos, atan: 
    539539        Trigonometry functions and inverses, operating on radians. 
    540     sinh, cos, tanh, asinh, acosh, atanh: 
     540    sinh, cosh, tanh, asinh, acosh, atanh: 
    541541        Hyperbolic trigonometry functions. 
    542542    atan2(y,x): 
Note: See TracChangeset for help on using the changeset viewer.