Changes in / [689b7c4:9f37726] in sasmodels


Ignore:
Location:
sasmodels
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/custom/__init__.py

    r3c852d4 r2a0c7a6  
    88to occur without error. 
    99""" 
    10 from __future__ import division, print_function 
    1110 
    12 import sys 
    1311import os 
    1412from os.path import basename, splitext 
     
    2826    def load_module_from_path(fullname, path): 
    2927        """load module from *path* as *fullname*""" 
    30         # Clear out old definitions, if any 
    31         if fullname in sys.modules: 
    32             del sys.modules[fullname] 
    3328        module = imp.load_source(fullname, os.path.expanduser(path)) 
    3429        #os.unlink(path+"c")  # remove the automatic pyc file 
  • sasmodels/model_test.py

    r479d0f3 r897ca7f  
    121121 
    122122            # test using dll if desired 
    123             if 'dll' in loaders or not core.HAVE_OPENCL: 
     123            if 'dll' in loaders: 
    124124                test_name = "Model: %s, Kernel: dll"%model_name 
    125125                test_method_name = "test_%s_dll" % model_info.id 
     
    270270 
    271271    # Build a test suite containing just the model 
    272     loaders = ['opencl'] if core.HAVE_OPENCL else ['dll'] 
     272    loaders = ['opencl'] 
    273273    models = [model] 
    274274    try: 
     
    288288        stream.writeln(tb) 
    289289 
    290     # Warn if there are no user defined tests. 
    291     # Note: the test suite constructed above only has one test in it, which 
    292     # runs through some smoke tests to make sure the model runs, then runs 
    293     # through the input-output pairs given in the model definition file.  To 
    294     # check if any such pairs are defined, therefore, we just need to check if 
    295     # they are in the first test of the test suite.  We do this with an 
    296     # iterator since we don't have direct access to the list of tests in the 
    297     # test suite. 
    298     for test in suite: 
    299         if not test.info.tests: 
    300             stream.writeln("Note: %s has no user defined tests."%model) 
    301         break 
    302     else: 
    303         stream.writeln("Note: no test suite created --- this should never happen") 
     290    # Check if there are user defined tests. 
     291    # Yes, it is naughty to peek into the structure of the test suite, and 
     292    # to assume that it contains only one test. 
     293    if not suite._tests[0].info.tests: 
     294        stream.writeln("Note: %s has no user defined tests."%model) 
    304295 
    305296 
     
    334325        models = models[1:] 
    335326    elif models and models[0] == 'opencl_and_dll': 
    336         loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
     327        loaders = ['opencl', 'dll'] 
    337328        models = models[1:] 
    338329    else: 
    339         loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
     330        loaders = ['opencl', 'dll'] 
    340331    if not models: 
    341332        print("""\ 
     
    366357    Run "nosetests sasmodels" on the command line to invoke it. 
    367358    """ 
    368     loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
    369     tests = make_suite(loaders, ['all']) 
     359    tests = make_suite(['opencl', 'dll'], ['all']) 
    370360    for test_i in tests: 
    371         # In order for nosetest to see the correct test name, need to set 
    372         # the description attribute of the returned function.  Since we 
    373         # can't do this for the returned instance, wrap it in a lambda and 
    374         # set the description on the lambda.  Otherwise we could just do: 
    375         #    yield test_i.run_all 
    376         L = lambda: test_i.run_all() 
    377         L.description = test_i.test_name 
    378         yield L 
     361        yield test_i.run_all 
    379362 
    380363 
  • sasmodels/models/multilayer_vesicle.py

    re77872e r9a4811a  
    55This model is a trivial extension of the core_shell_sphere function to include 
    66*N* shells where the core is filled with solvent and the shells are interleaved 
    7 with layers of solvent. For *N = 1*, this returns the same as the vesicle model, 
    8 except for the normalisation, which here is to outermost volume. 
    9 The shell thicknessess and SLD are constant for all shells as expected for 
     7with layers of solvent. For *N = 1*, this returns the same as the vesicle model. 
     8The shell thicknessess and SLD are constant across all shells as expected for 
    109a multilayer vesicle. 
    1110 
     
    2524.. note: 
    2625    The outer most radius 
    27     $radius + n_pairs * thick_shell + (n_pairs - 1) * thick_solvent$ 
    28     is used for both the volume fraction normalization and for the  
    29     effective radius for *S(Q)* when $P(Q) * S(Q)$ is applied. 
     26    $radius + n_pairs * thicn_shell + (n_pairs - 1) * thick_solvent$ 
     27    is used as the effective radius for *S(Q)* when $P(Q) * S(Q)$ is applied. 
    3028 
    3129For information about polarised and magnetic scattering, see 
     
    6462    sld_solvent: solvent scattering length density 
    6563    sld: shell scattering length density 
    66     n_pairs:number of "shell plus solvent" layer pairs 
     64    n_pairs:number of pairs of water/shell 
    6765    background: incoherent background 
    6866        """ 
     
    7371parameters = [ 
    7472    ["volfraction", "",  0.05, [0.0, 1],  "", "volume fraction of vesicles"], 
    75     ["radius", "Ang", 60.0, [0.0, inf],  "", "radius of solvent filled core"], 
    76     ["thick_shell", "Ang",        10.0, [0.0, inf],  "", "thickness of one shell"], 
    77     ["thick_solvent", "Ang",        10.0, [0.0, inf],  "", "solvent thickness between shells"], 
    78     ["sld_solvent",    "1e-6/Ang^2",  6.4, [-inf, inf], "sld", "solvent scattering length density"], 
     73    ["radius", "Ang", 60.0, [0.0, inf],  "", "Core radius of the multishell"], 
     74    ["thick_shell", "Ang",        10.0, [0.0, inf],  "", "Shell thickness"], 
     75    ["thick_solvent", "Ang",        10.0, [0.0, inf],  "", "Water thickness"], 
     76    ["sld_solvent",    "1e-6/Ang^2",  6.4, [-inf, inf], "sld", "Core scattering length density"], 
    7977    ["sld",   "1e-6/Ang^2",  0.4, [-inf, inf], "sld", "Shell scattering length density"], 
    80     ["n_pairs",     "",            2.0, [1.0, inf],  "", "Number of shell plus solvent layer pairs"], 
     78    ["n_pairs",     "",            2.0, [1.0, inf],  "", "Number of pairs of water and shell"], 
    8179    ] 
    8280# pylint: enable=bad-whitespace, line-too-long 
  • sasmodels/models/vesicle.py

    re77872e r42356c8  
    7575        thickness: the shell thickness 
    7676        sld: the shell SLD 
    77         sld_solvent: the solvent (and core) SLD 
     77        sld_slovent: the solvent (and core) SLD 
    7878        background: incoherent background 
    7979        volfraction: shell volume fraction 
  • sasmodels/sasview_model.py

    r9f37726 r9f37726  
    123123        if model.name == "": 
    124124            model.name = splitext(basename(path))[0] 
    125         if not hasattr(model, 'filename'): 
    126             model.filename = kernel_module.__file__ 
    127125    except AttributeError: 
    128126        model_info = modelinfo.make_model_info(kernel_module) 
    129127        model = _make_model_from_info(model_info) 
    130128 
    131     # If a model name already exists and we are loading a different model, 
    132     # use the model file name as the model name. 
    133     if model.name in MODELS and not model.filename == MODELS[model.name].filename: 
    134         _previous_name = model.name 
    135         model.name = model.id 
    136          
    137         # If the new model name is still in the model list (for instance, 
    138         # if we put a cylinder.py in our plug-in directory), then append 
    139         # an identifier. 
    140         if model.name in MODELS and not model.filename == MODELS[model.name].filename: 
    141             model.name = model.id + '_user' 
    142         logging.info("Model %s already exists: using %s [%s]", _previous_name, model.name, model.filename) 
     129    # If we are trying to load a model that already exists, 
     130    # append a version number to its name. 
     131    # Note that models appear to be periodically reloaded  
     132    # by SasView and keeping track of whether we are reloading  
     133    # a model or loading it for the first time is tricky. 
     134    # For now, just allow one custom model of a given name. 
     135    if model.name in MODELS: 
     136        model.name = "%s_v2" % model.name 
    143137 
    144138    MODELS[model.name] = model 
     
    169163    attrs = _generate_model_attributes(model_info) 
    170164    attrs['__init__'] = __init__ 
    171     attrs['filename'] = model_info.filename 
    172165    ConstructedModel = type(model_info.name, (SasviewModel,), attrs) # type: SasviewModelType 
    173166    return ConstructedModel 
     
    327320        else: 
    328321            hidden = set() 
    329         if self._model_info.structure_factor: 
    330             hidden.add('scale') 
    331             hidden.add('background') 
    332             self._model_info.parameters.defaults['background'] = 0. 
    333322 
    334323        self._persistency_dict = {} 
     
    676665                return [self.multiplicity], [1.0] 
    677666            else: 
    678                 # For hidden parameters use the default value. 
    679                 value = self._model_info.parameters.defaults.get(par.name, np.NaN) 
    680                 return [value], [1.0] 
     667                return [np.NaN], [1.0] 
    681668        elif par.polydisperse: 
    682669            dis = self.dispersion[par.name] 
     
    699686    cylinder = Cylinder() 
    700687    return cylinder.evalDistribution([0.1, 0.1]) 
    701  
    702 def test_structure_factor(): 
    703     # type: () -> float 
    704     """ 
    705     Test that a sasview model (cylinder) can be run. 
    706     """ 
    707     Model = _make_standard_model('hardsphere') 
    708     model = Model() 
    709     value = model.evalDistribution([0.1, 0.1]) 
    710     if np.isnan(value): 
    711         raise ValueError("hardsphere returns null") 
    712688 
    713689def test_rpa(): 
Note: See TracChangeset for help on using the changeset viewer.