Changeset ec52ea1 in sasview for src


Ignore:
Timestamp:
Aug 13, 2018 4:47:22 PM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
Children:
0863065, d53abd2, f05f6ff
Parents:
3bfcd9e (diff), d788619 (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:
Paul Butler <butlerpd@…> (08/13/18 16:47:22)
git-committer:
GitHub <noreply@…> (08/13/18 16:47:22)
Message:

Merge pull request #164 from SasView?/ticket-1132

Load data for slit size calculator - 1132

Closes #1132

Location:
src/sas
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/calculator/slit_length_calculator_panel.py

    r7432acb rd788619  
    248248            Complete the loading and compute the slit size 
    249249        """ 
     250        if isinstance(data, list): 
     251            data = data[0] 
    250252        if data is None or data.__class__.__name__ == 'Data2D': 
    251253            if self.parent.parent is None: 
  • src/sas/sascalc/fit/pagestate.py

    r3b070a0 r59873e1  
    1313################################################################################ 
    1414import time 
     15import re 
    1516import os 
    1617import sys 
     
    962963        if node.get('version'): 
    963964            # Get the version for model conversion purposes 
    964             self.version = tuple(int(e) for e in 
    965                                  str.split(node.get('version'), ".")) 
     965            x = re.sub('[^\d.]', '', node.get('version')) 
     966            self.version = tuple(int(e) for e in str.split(x, ".")) 
    966967            # The tuple must be at least 3 items long 
    967968            while len(self.version) < 3: 
  • src/sas/sasgui/perspectives/calculator/pyconsole.py

    r4627657 re2663b7  
    2828    Check that the model on the path can run. 
    2929    """ 
     30    # TODO: fix model caching 
     31    # model_test.run_one() is directly forcing a reload of the module, but 
     32    # sasview_model is caching models that have already been loaded. 
     33    # If the sasview load happens before the test, then the module is 
     34    # reloaded out from under it, which causes the global variables in 
     35    # the model function definitions to be cleared (at least in python 2.7). 
     36    # To fix the proximal problem of models failing on test, perform the 
     37    # run_one() tests first.  To fix the deeper problem we should either 
     38    # remove caching from sasmodels.sasview_model.load_custom_model() or 
     39    # add caching to sasmodels.custom.load_custom_kernel_module().  Another 
     40    # option is to add a runTests method to SasviewModel which runs the 
     41    # test suite directly from the model info structure.  Probably some 
     42    # combination of options: 
     43    #    (1) have this function (check_model) operate on a loaded model 
     44    #    so that caching isn't needed in sasview_models.load_custom_model 
     45    #    (2) add the runTests method to SasviewModel so that tests can 
     46    #    be run on a loaded module. 
     47    # 
     48    # Also, note that the model test suite runs the equivalent of the 
     49    # "try running the model" block below, and doesn't need to be run 
     50    # twice.  The reason for duplicating the block here is to generate 
     51    # an exception that show_model_output can catch.  Need to write the 
     52    # runTests method so that it returns success flag as well as output 
     53    # string so that the extra test is not necessary. 
     54 
     55    # check the model's unit tests run 
     56    from sasmodels.model_test import run_one 
     57    result = run_one(path) 
     58 
     59    # remove cached version of the model, if any 
     60    from sasmodels import sasview_model 
     61    sasview_model.MODEL_BY_PATH.pop(path, None) 
     62 
    3063    # try running the model 
    31     from sasmodels.sasview_model import load_custom_model 
    32     Model = load_custom_model(path) 
     64    Model = sasview_model.load_custom_model(path) 
    3365    model = Model() 
    3466    q =  np.array([0.01, 0.1]) 
     
    3668    qx, qy =  np.array([0.01, 0.01]), np.array([0.1, 0.1]) 
    3769    Iqxy = model.evalDistribution([qx, qy]) 
    38  
    39     # check the model's unit tests run 
    40     from sasmodels.model_test import run_one 
    41     result = run_one(path) 
    4270 
    4371    return result 
Note: See TracChangeset for help on using the changeset viewer.