Changes in / [5a22548:e77872e] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sasview_model.py

    r2f2c70c red10b57  
    127127        model = _make_model_from_info(model_info) 
    128128 
    129     # If a model name already exists and we are loading a different model, 
    130     # use the model file name as the model name. 
    131     if model.name in MODELS and not model.filename == MODELS[model.name].filename: 
    132         _previous_name = model.name 
    133         model.name = model.id 
    134          
    135         # If the new model name is still in the model list (for instance, 
    136         # if we put a cylinder.py in our plug-in directory), then append 
    137         # an identifier. 
    138         if model.name in MODELS and not model.filename == MODELS[model.name].filename: 
    139             model.name = model.id + '_user' 
    140         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 
    141137 
    142138    MODELS[model.name] = model 
     
    167163    attrs = _generate_model_attributes(model_info) 
    168164    attrs['__init__'] = __init__ 
    169     attrs['filename'] = model_info.filename 
    170165    ConstructedModel = type(model_info.name, (SasviewModel,), attrs) # type: SasviewModelType 
    171166    return ConstructedModel 
     
    325320        else: 
    326321            hidden = set() 
    327         if self._model_info.structure_factor: 
    328             hidden.add('scale') 
    329             hidden.add('background') 
    330             self._model_info.parameters.defaults['background'] = 0. 
    331322 
    332323        self._persistency_dict = {} 
     
    677668                return [self.multiplicity], [1.0] 
    678669            else: 
    679                 # For hidden parameters use the default value. 
    680                 value = self._model_info.parameters.defaults.get(par.name, np.NaN) 
    681                 return [value], [1.0] 
     670                return [np.NaN], [1.0] 
    682671        elif par.polydisperse: 
    683672            dis = self.dispersion[par.name] 
     
    700689    cylinder = Cylinder() 
    701690    return cylinder.evalDistribution([0.1, 0.1]) 
    702  
    703 def test_structure_factor(): 
    704     # type: () -> float 
    705     """ 
    706     Test that a sasview model (cylinder) can be run. 
    707     """ 
    708     Model = _make_standard_model('hardsphere') 
    709     model = Model() 
    710     value = model.evalDistribution([0.1, 0.1]) 
    711     if np.isnan(value): 
    712         raise ValueError("hardsphere returns null") 
    713691 
    714692def test_rpa(): 
Note: See TracChangeset for help on using the changeset viewer.