Changeset 73cbc5b in sasmodels for sasmodels/model_test.py


Ignore:
Timestamp:
Jun 7, 2017 9:36:23 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
4f0c993
Parents:
b34fc77 (diff), c1114bf (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.
Message:

Merge branch 'master' into ticket-776-orientation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/model_test.py

    reaa4458 r73cbc5b  
    8585        skip = [] 
    8686    for model_name in models: 
    87         if model_name in skip: continue 
     87        if model_name in skip: 
     88            continue 
    8889        model_info = load_model_info(model_name) 
    8990 
     
    239240            multiple = [test for test in self.info.tests 
    240241                        if isinstance(test[2], list) 
    241                             and not all(result is None for result in test[2])] 
     242                        and not all(result is None for result in test[2])] 
    242243            tests_has_1D_multiple = any(isinstance(test[1][0], float) 
    243244                                        for test in multiple) 
     
    262263            user_pars, x, y = test 
    263264            pars = expand_pars(self.info.parameters, user_pars) 
     265            invalid = invalid_pars(self.info.parameters, pars) 
     266            if invalid: 
     267                raise ValueError("Unknown parameters in test: " + ", ".join(invalid)) 
    264268 
    265269            if not isinstance(y, list): 
     
    305309 
    306310    return ModelTestCase 
     311 
     312def invalid_pars(partable, pars): 
     313    # type: (ParameterTable, Dict[str, float]) 
     314    """ 
     315    Return a list of parameter names that are not part of the model. 
     316    """ 
     317    names = set(p.id for p in partable.call_parameters) 
     318    invalid = [] 
     319    for par in sorted(pars.keys()): 
     320        parts = par.split('_pd') 
     321        if len(parts) > 1 and parts[1] not in ("", "_n", "nsigma", "type"): 
     322            invalid.append(par) 
     323            continue 
     324        if parts[0] not in names: 
     325            invalid.append(par) 
     326    return invalid 
     327 
    307328 
    308329def is_near(target, actual, digits=5): 
Note: See TracChangeset for help on using the changeset viewer.