Changeset 2547694 in sasmodels


Ignore:
Timestamp:
Jul 28, 2016 8:23:10 AM (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:
0f00d95
Parents:
20317b3
Message:

lint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified sasmodels/core.py

    rd2d6100 r2547694  
    66__all__ = [ 
    77    "list_models", "load_model", "load_model_info", 
    8     "build_model", "precompile_dll", 
     8    "build_model", "precompile_dlls", 
    99    ] 
    1010 
    1111import os 
    12 from os.path import basename, dirname, join as joinpath, splitext 
     12from os.path import basename, dirname, join as joinpath 
    1313from glob import glob 
    1414 
     
    5757#    build_model 
    5858 
     59KINDS = ("all", "py", "c", "double", "single", "1d", "2d", 
     60         "nonmagnetic", "magnetic") 
    5961def list_models(kind=None): 
    6062    # type: () -> List[str] 
     
    6264    Return the list of available models on the model path. 
    6365    """ 
    64     KINDS = ("all", "py", "c", "double", "single", "1d", "2d", "nonmagnetic", "magnetic") 
    6566    if kind and kind not in KINDS: 
    66         raise ValueError("kind not in "+", ".join(KINDS)) 
     67        raise ValueError("kind not in " + ", ".join(KINDS)) 
    6768    root = dirname(__file__) 
    6869    files = sorted(glob(joinpath(root, 'models', "[a-zA-Z]*.py"))) 
     
    7374 
    7475def _matches(name, kind): 
    75     if kind is None or kind=="all": 
     76    if kind is None or kind == "all": 
    7677        return True 
    7778    info = load_model_info(name) 
     
    8586    elif kind == "single" and info.single: 
    8687        return True 
    87     elif kind == "2d" and any(p.type=='orientation' for p in pars): 
    88         return True 
    89     elif kind == "1d" and any(p.type!='orientation' for p in pars): 
    90         return True 
    91     elif kind == "magnetic" and any(p.type=='sld' for p in pars): 
    92         return True 
    93     elif kind == "nonmagnetic" and any(p.type!='sld' for p in pars): 
     88    elif kind == "2d" and any(p.type == 'orientation' for p in pars): 
     89        return True 
     90    elif kind == "1d" and any(p.type != 'orientation' for p in pars): 
     91        return True 
     92    elif kind == "magnetic" and any(p.type == 'sld' for p in pars): 
     93        return True 
     94    elif kind == "nonmagnetic" and any(p.type != 'sld' for p in pars): 
    9495        return True 
    9596    return False 
     
    157158            return mixture.MixtureModel(model_info, models) 
    158159        elif composition_type == 'product': 
    159             from . import product 
    160160            P, S = models 
    161161            return product.ProductModel(model_info, P, S) 
     
    217217    if platform is None: 
    218218        platform = "ocl" 
    219     if platform=="ocl" and not HAVE_OPENCL: 
     219    if platform == "ocl" and not HAVE_OPENCL: 
    220220        platform = "dll" 
    221221 
     
    226226 
    227227    # Convert special type names "half", "fast", and "quad" 
    228     fast = (dtype=="fast") 
     228    fast = (dtype == "fast") 
    229229    if fast: 
    230230        dtype = "single" 
    231     elif dtype=="quad": 
     231    elif dtype == "quad": 
    232232        dtype = "longdouble" 
    233     elif dtype=="half": 
     233    elif dtype == "half": 
    234234        dtype = "f16" 
    235235 
    236236    # Convert dtype string to numpy dtype. 
    237237    if dtype is None: 
    238         numpy_dtype = generate.F32 if platform=="ocl" and model_info.single else generate.F64 
     238        numpy_dtype = (generate.F32 if platform == "ocl" and model_info.single 
     239                       else generate.F64) 
    239240    else: 
    240241        numpy_dtype = np.dtype(dtype) 
    241242 
    242243    # Make sure that the type is supported by opencl, otherwise use dll 
    243     if platform=="ocl": 
     244    if platform == "ocl": 
    244245        env = kernelcl.environment() 
    245246        if not env.has_type(numpy_dtype): 
     
    250251    return numpy_dtype, fast, platform 
    251252 
    252 if __name__ == "__main__": 
     253def list_models_main(): 
    253254    import sys 
    254255    kind = sys.argv[1] if len(sys.argv) > 1 else "all" 
    255256    print("\n".join(list_models(kind))) 
     257 
     258if __name__ == "__main__": 
     259    list_models_main() 
Note: See TracChangeset for help on using the changeset viewer.