Changeset d0b0f5d in sasmodels for sasmodels/weights.py


Ignore:
Timestamp:
Mar 31, 2019 8:20:32 AM (5 years ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
d827c5e
Parents:
7050455 (diff), e2da671 (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:
Andrew Jackson <andrew.jackson@…> (03/31/19 08:20:32)
git-committer:
GitHub <noreply@…> (03/31/19 08:20:32)
Message:

Merge pull request #67 from SasView?/ticket-608-user-defined-weights

Ticket 608 user defined weights

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/weights.py

    rb297ba9 rd0b0f5d  
    230230)) 
    231231 
     232SAS_WEIGHTS_PATH = "~/.sasview/weights" 
     233def load_weights(pattern=None): 
     234    # type: (str) -> None 
     235    """ 
     236    Load dispersion distributions matching the given glob pattern 
     237    """ 
     238    import logging 
     239    import os 
     240    import os.path 
     241    import glob 
     242    import traceback 
     243    from .custom import load_custom_kernel_module 
     244    if pattern is None: 
     245        path = os.environ.get("SAS_WEIGHTS_PATH", SAS_WEIGHTS_PATH) 
     246        pattern = os.path.join(path, "*.py") 
     247    for filename in sorted(glob.glob(os.path.expanduser(pattern))): 
     248        try: 
     249            #print("loading weights from", filename) 
     250            module = load_custom_kernel_module(filename) 
     251            MODELS[module.Dispersion.type] = module.Dispersion 
     252        except Exception as exc: 
     253            logging.error(traceback.format_exc(exc)) 
    232254 
    233255def get_weights(disperser, n, width, nsigmas, value, limits, relative): 
Note: See TracChangeset for help on using the changeset viewer.