Changeset c499331 in sasmodels for sasmodels/core.py


Ignore:
Timestamp:
Mar 25, 2016 5:45:02 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
d19962c
Parents:
5ff1b03
Message:

progress on having compare.py recognize vector parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/core.py

    r5ff1b03 rc499331  
    2929] 
    3030 
     31try: 
     32    # Python 3.5 and up 
     33    from importlib.util import spec_from_file_location, module_from_spec 
     34    def load_module(fullname, path): 
     35        spec = spec_from_file_location(fullname, path) 
     36        module = module_from_spec(spec) 
     37        spec.loader.exec_module(module) 
     38        return module 
     39except ImportError: 
     40    # CRUFT: python 2 
     41    import imp 
     42    def load_module(fullname, path): 
     43        module = imp.load_source(fullname, path) 
     44        return module 
     45 
    3146def list_models(): 
    3247    """ 
     
    5065    Load model info and build model. 
    5166    """ 
    52     return build_model(load_model_info(model_name), **kw) 
     67    if model_name.endswith('.py'): 
     68        model_info = load_model_info_from_path(model_name) 
     69    else: 
     70        model_info = load_model_info(model_name) 
     71    return build_model(model_info, **kw) 
    5372 
    5473def load_model_info_from_path(path): 
     
    6382    # though it doesn't actually exist.  imp.load_source doesn't seem 
    6483    # to care. 
    65     kernel_module = imp.load_source('sasmodels.custom.'+name, path) 
     84    import sasmodels.custom 
     85    kernel_module = load_module('sasmodels.custom.'+name, path) 
    6686 
    6787    # Now that we have the module, we can load it as usual 
Note: See TracChangeset for help on using the changeset viewer.