Changeset b297ba9 in sasmodels for sasmodels/model_test.py


Ignore:
Timestamp:
Mar 20, 2019 5:03:50 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:
4e28511
Parents:
0d362b7
Message:

lint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/model_test.py

    rd92182f rb297ba9  
    6161import numpy as np  # type: ignore 
    6262 
    63 from . import core 
    6463from .core import list_models, load_model_info, build_model 
    6564from .direct_model import call_kernel, call_Fq 
     
    137136        test_method_name = "test_%s_python" % model_info.id 
    138137        test = ModelTestCase(test_name, model_info, 
    139                                 test_method_name, 
    140                                 platform="dll",  # so that 
    141                                 dtype="double", 
    142                                 stash=stash) 
     138                             test_method_name, 
     139                             platform="dll",  # so that 
     140                             dtype="double", 
     141                             stash=stash) 
    143142        suite.addTest(test) 
    144143    else:   # kernel implemented in C 
     
    149148            test_method_name = "test_%s_dll" % model_info.id 
    150149            test = ModelTestCase(test_name, model_info, 
    151                                     test_method_name, 
    152                                     platform="dll", 
    153                                     dtype="double", 
    154                                     stash=stash) 
     150                                 test_method_name, 
     151                                 platform="dll", 
     152                                 dtype="double", 
     153                                 stash=stash) 
    155154            suite.addTest(test) 
    156155 
     
    164163            # presence of *single=False* in the model file. 
    165164            test = ModelTestCase(test_name, model_info, 
    166                                     test_method_name, 
    167                                     platform="ocl", dtype=None, 
    168                                     stash=stash) 
     165                                 test_method_name, 
     166                                 platform="ocl", dtype=None, 
     167                                 stash=stash) 
    169168            #print("defining", test_name) 
    170169            suite.addTest(test) 
     
    179178            # presence of *single=False* in the model file. 
    180179            test = ModelTestCase(test_name, model_info, 
    181                                     test_method_name, 
    182                                     platform="cuda", dtype=None, 
    183                                     stash=stash) 
     180                                 test_method_name, 
     181                                 platform="cuda", dtype=None, 
     182                                 stash=stash) 
    184183            #print("defining", test_name) 
    185184            suite.addTest(test) 
     
    413412# CRUFT: old interface; should be deprecated and removed 
    414413def run_one(model_name): 
     414    # type: (str) -> str 
     415    """ 
     416    [Deprecated] Run the tests associated with *model_name*. 
     417 
     418    Use the following instead:: 
     419 
     420        succss, output = check_model(load_model_info(model_name)) 
     421    """ 
    415422    # msg = "use check_model(model_info) rather than run_one(model_name)" 
    416423    # warnings.warn(msg, category=DeprecationWarning, stacklevel=2) 
     
    421428        return output 
    422429 
    423     success, output = check_model(model_info) 
     430    _, output = check_model(model_info) 
    424431    return output 
    425432 
    426433def check_model(model_info): 
    427     # type: (ModelInfo) -> str 
     434    # type: (ModelInfo) -> Tuple[bool, str] 
    428435    """ 
    429436    Run the tests for a single model, capturing the output. 
     
    492499        loaders.append('cuda') 
    493500    tests = make_suite(loaders, ['all']) 
    494     def build_test(test): 
     501    def _build_test(test): 
    495502        # In order for nosetest to show the test name, wrap the test.run_all 
    496503        # instance in function that takes the test name as a parameter which 
     
    510517 
    511518    for test in tests: 
    512         yield build_test(test) 
     519        yield _build_test(test) 
    513520 
    514521 
     
    539546                        "models will be tested.  See core.list_models() for " 
    540547                        "names of other groups, such as 'py' or 'single'.") 
    541     args, models = parser.parse_known_args() 
    542  
    543     if args.engine == "opencl": 
     548    opts = parser.parse_args() 
     549 
     550    if opts.engine == "opencl": 
    544551        if not use_opencl(): 
    545552            print("opencl is not available") 
    546553            return 1 
    547554        loaders = ['opencl'] 
    548     elif args.engine == "dll": 
     555    elif opts.engine == "dll": 
    549556        loaders = ["dll"] 
    550     elif args.engine == "cuda": 
     557    elif opts.engine == "cuda": 
    551558        if not use_cuda(): 
    552559            print("cuda is not available") 
    553560            return 1 
    554561        loaders = ['cuda'] 
    555     elif args.engine == "all": 
     562    elif opts.engine == "all": 
    556563        loaders = ['dll'] 
    557564        if use_opencl(): 
     
    560567            loaders.append('cuda') 
    561568    else: 
    562         print("unknown engine " + args.engine) 
     569        print("unknown engine " + opts.engine) 
    563570        return 1 
    564571 
    565     runner = TestRunner(verbosity=args.verbose, **test_args) 
    566     result = runner.run(make_suite(loaders, args.models)) 
     572    runner = TestRunner(verbosity=opts.verbose, **test_args) 
     573    result = runner.run(make_suite(loaders, opts.models)) 
    567574    return 1 if result.failures or result.errors else 0 
    568575 
Note: See TracChangeset for help on using the changeset viewer.