Changeset ed10b57 in sasmodels


Ignore:
Timestamp:
Oct 9, 2016 10:35:59 AM (8 years ago)
Author:
mathieu
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3c852d4, 9f37726
Parents:
3f5a566
Message:

Allow loading of custom model of the same name as a std model (append version). Re #673

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sasview_model.py

    r5b37fd6 red10b57  
    115115    Load a custom model given the model path. 
    116116    """ 
    117     #print("load custom", path) 
    118117    kernel_module = custom.load_custom_kernel_module(path) 
    119118    try: 
     
    127126        model_info = modelinfo.make_model_info(kernel_module) 
    128127        model = _make_model_from_info(model_info) 
     128 
     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 
     137 
    129138    MODELS[model.name] = model 
    130139    return model 
Note: See TracChangeset for help on using the changeset viewer.