Changeset d92182f in sasmodels for sasmodels/core.py


Ignore:
Timestamp:
Mar 11, 2019 9:30:49 PM (5 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:
d8eaa3d
Parents:
aee8dfb
Message:

tweak option handling for model_test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/core.py

    r07646b6 rd92182f  
    6464        * all: all models 
    6565        * py: python models only 
    66         * c: compiled models only 
    67         * single: models which support single precision 
    68         * double: models which require double precision 
    69         * opencl: controls if OpenCL is supperessed 
    70         * 1d: models which are 1D only, or 2D using abs(q) 
    71         * 2d: models which can be 2D 
    72         * magnetic: models with an sld 
    73         * nommagnetic: models without an sld 
     66        * c: c models only 
     67        * single: c models which support single precision 
     68        * double: c models which require double precision 
     69        * opencl: c models which run in opencl 
     70        * dll: c models which do not run in opencl 
     71        * 1d: models without orientation 
     72        * 2d: models with orientation 
     73        * magnetic: models supporting magnetic sld 
     74        * nommagnetic: models without magnetic parameter 
    7475 
    7576    For multiple conditions, combine with plus.  For example, *c+single+2d* 
     
    9596    info = load_model_info(name) 
    9697    pars = info.parameters.kernel_parameters 
    97     if kind == "py" and callable(info.Iq): 
    98         return True 
    99     elif kind == "c" and not callable(info.Iq): 
    100         return True 
    101     elif kind == "double" and not info.single: 
    102         return True 
    103     elif kind == "single" and info.single: 
    104         return True 
    105     elif kind == "opencl" and info.opencl: 
    106         return True 
    107     elif kind == "2d" and any(p.type == 'orientation' for p in pars): 
    108         return True 
    109     elif kind == "1d" and all(p.type != 'orientation' for p in pars): 
    110         return True 
    111     elif kind == "magnetic" and any(p.type == 'sld' for p in pars): 
    112         return True 
    113     elif kind == "nonmagnetic" and any(p.type != 'sld' for p in pars): 
    114         return True 
     98    # TODO: may be adding Fq to the list at some point 
     99    is_pure_py = callable(info.Iq) 
     100    if kind == "py": 
     101        return is_pure_py 
     102    elif kind == "c": 
     103        return not is_pure_py 
     104    elif kind == "double": 
     105        return not info.single and not is_pure_py 
     106    elif kind == "single": 
     107        return info.single and not is_pure_py 
     108    elif kind == "opencl": 
     109        return info.opencl 
     110    elif kind == "dll": 
     111        return not info.opencl and not is_pure_py 
     112    elif kind == "2d": 
     113        return any(p.type == 'orientation' for p in pars) 
     114    elif kind == "1d": 
     115        return all(p.type != 'orientation' for p in pars) 
     116    elif kind == "magnetic": 
     117        return any(p.type == 'sld' for p in pars) 
     118    elif kind == "nonmagnetic": 
     119        return not any(p.type == 'sld' for p in pars) 
    115120    return False 
    116121 
     
    317322    return numpy_dtype, fast, platform 
    318323 
    319 def list_models_main(): 
    320     # type: () -> None 
    321     """ 
    322     Run list_models as a main program.  See :func:`list_models` for the 
    323     kinds of models that can be requested on the command line. 
    324     """ 
    325     import sys 
    326     kind = sys.argv[1] if len(sys.argv) > 1 else "all" 
    327     print("\n".join(list_models(kind))) 
    328  
    329324def test_composite_order(): 
    330325    def test_models(fst, snd): 
     
    386381    assert target == actual, "%s != %s"%(target, actual) 
    387382 
     383def list_models_main(): 
     384    # type: () -> None 
     385    """ 
     386    Run list_models as a main program.  See :func:`list_models` for the 
     387    kinds of models that can be requested on the command line. 
     388    """ 
     389    import sys 
     390    kind = sys.argv[1] if len(sys.argv) > 1 else "all" 
     391    try: 
     392        models = list_models(kind) 
     393    except Exception as exc: 
     394        print(list_models.__doc__) 
     395        return 1 
     396 
     397    print("\n".join(list_models(kind))) 
     398 
    388399if __name__ == "__main__": 
    389400    list_models_main() 
Note: See TracChangeset for help on using the changeset viewer.