Changeset 5124c969 in sasmodels


Ignore:
Timestamp:
Feb 27, 2017 5:55:59 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
c713c85
Parents:
a3002be
Message:

allow multicompare to select opencl+single+1d

Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare_many.py

    r424fe00 r5124c969  
    106106    header = ('\n"Model","%s","Count","%d","Dimension","%s"' 
    107107              % (name, N, "2D" if is_2d else "1D")) 
    108     if not mono: header += ',"Cutoff",%g'%(cutoff,) 
     108    if not mono: 
     109        header += ',"Cutoff",%g'%(cutoff,) 
    109110    print(header) 
    110111 
     
    161162    max_diff = [0] 
    162163    for k in range(N): 
    163         print("%s %d"%(name, k), file=sys.stderr) 
     164        print("Model %s %d"%(name, k+1), file=sys.stderr) 
    164165        seed = np.random.randint(1e6) 
    165166        pars_i = randomize_pars(model_info, pars, seed) 
    166167        constrain_pars(model_info, pars_i) 
    167         constrain_new_to_old(model_info, pars_i) 
     168        if 'sasview' in (base, comp): 
     169            constrain_new_to_old(model_info, pars_i) 
    168170        if mono: 
    169171            pars_i = suppress_pd(pars_i) 
     
    204206    print("""\ 
    205207 
    206 MODEL is the model name of the model or "all" for all the models 
    207 in alphabetical order. 
     208MODEL is the model name of the model or one of the model types listed in 
     209sasmodels.core.list_models (all, py, c, double, single, opencl, 1d, 2d, 
     210nonmagnetic, magnetic).  Model types can be combined, such as 2d+single. 
    208211 
    209212COUNT is the number of randomly generated parameter sets to try. A value 
     
    237240        return 
    238241 
    239     model = argv[0] 
    240     if not (model in MODELS) and (model != "all"): 
    241         print('Bad model %s.  Use "all" or one of:'%model) 
     242    target = argv[0] 
     243    try: 
     244        model_list = [target] if target in MODELS else core.list_models(target) 
     245    except ValueError: 
     246        print('Bad model %s.  Use model type or one of:'%model) 
    242247        print_models() 
     248        print('model types: all, py, c, double, single, opencl, 1d, 2d, nonmagnetic, magnetic') 
    243249        return 
    244250    try: 
     
    258264    data, index = make_data({'qmax':1.0, 'is2d':is2D, 'nq':Nq, 'res':0., 
    259265                             'accuracy': 'Low', 'view':'log', 'zero': False}) 
    260     model_list = [model] if model != "all" else MODELS 
    261266    for model in model_list: 
    262267        compare_instance(model, data, index, N=count, mono=mono, 
  • sasmodels/core.py

    r52e9a45 r5124c969  
    6969        * magnetic: models with an sld 
    7070        * nommagnetic: models without an sld 
    71     """ 
    72     if kind and kind not in KINDS: 
     71 
     72    For multiple conditions, combine with plus.  For example, *c+single+2d* 
     73    would return all oriented models implemented in C which can be computed 
     74    accurately with single precision arithmetic. 
     75    """ 
     76    if kind and any(k not in KINDS for k in kind.split('+')): 
    7377        raise ValueError("kind not in " + ", ".join(KINDS)) 
    7478    files = sorted(glob(joinpath(generate.MODEL_PATH, "[a-zA-Z]*.py"))) 
    7579    available_models = [basename(f)[:-3] for f in files] 
    76     selected = [name for name in available_models if _matches(name, kind)] 
     80    if kind and '+' in kind: 
     81        all_kinds = kind.split('+') 
     82        condition = lambda name: all(_matches(name, k) for k in all_kinds) 
     83    else: 
     84        condition = lambda name: _matches(name, kind) 
     85    selected = [name for name in available_models if condition(name)] 
    7786 
    7887    return selected 
  • sasmodels/modelinfo.py

    r85fe7f8 r5124c969  
    730730    info.docs = kernel_module.__doc__ 
    731731    info.category = getattr(kernel_module, 'category', None) 
    732     info.single = getattr(kernel_module, 'single', True) 
    733     info.opencl = getattr(kernel_module, 'opencl', True) 
    734732    info.structure_factor = getattr(kernel_module, 'structure_factor', False) 
    735733    info.profile_axes = getattr(kernel_module, 'profile_axes', ['x', 'y']) 
     
    745743    info.profile = getattr(kernel_module, 'profile', None) # type: ignore 
    746744    info.sesans = getattr(kernel_module, 'sesans', None) # type: ignore 
     745    # Default single and opencl to True for C models.  Python models have callable Iq. 
     746    info.opencl = getattr(kernel_module, 'opencl', not callable(info.Iq)) 
     747    info.single = getattr(kernel_module, 'single', not callable(info.Iq)) 
    747748 
    748749    # multiplicity info 
Note: See TracChangeset for help on using the changeset viewer.