Changeset b297ba9 in sasmodels for sasmodels/model_test.py
- Timestamp:
- Mar 20, 2019 5:03:50 PM (5 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/model_test.py
rd92182f rb297ba9 61 61 import numpy as np # type: ignore 62 62 63 from . import core64 63 from .core import list_models, load_model_info, build_model 65 64 from .direct_model import call_kernel, call_Fq … … 137 136 test_method_name = "test_%s_python" % model_info.id 138 137 test = ModelTestCase(test_name, model_info, 139 140 141 142 138 test_method_name, 139 platform="dll", # so that 140 dtype="double", 141 stash=stash) 143 142 suite.addTest(test) 144 143 else: # kernel implemented in C … … 149 148 test_method_name = "test_%s_dll" % model_info.id 150 149 test = ModelTestCase(test_name, model_info, 151 152 153 154 150 test_method_name, 151 platform="dll", 152 dtype="double", 153 stash=stash) 155 154 suite.addTest(test) 156 155 … … 164 163 # presence of *single=False* in the model file. 165 164 test = ModelTestCase(test_name, model_info, 166 167 168 165 test_method_name, 166 platform="ocl", dtype=None, 167 stash=stash) 169 168 #print("defining", test_name) 170 169 suite.addTest(test) … … 179 178 # presence of *single=False* in the model file. 180 179 test = ModelTestCase(test_name, model_info, 181 182 183 180 test_method_name, 181 platform="cuda", dtype=None, 182 stash=stash) 184 183 #print("defining", test_name) 185 184 suite.addTest(test) … … 413 412 # CRUFT: old interface; should be deprecated and removed 414 413 def 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 """ 415 422 # msg = "use check_model(model_info) rather than run_one(model_name)" 416 423 # warnings.warn(msg, category=DeprecationWarning, stacklevel=2) … … 421 428 return output 422 429 423 success, output = check_model(model_info)430 _, output = check_model(model_info) 424 431 return output 425 432 426 433 def check_model(model_info): 427 # type: (ModelInfo) -> str434 # type: (ModelInfo) -> Tuple[bool, str] 428 435 """ 429 436 Run the tests for a single model, capturing the output. … … 492 499 loaders.append('cuda') 493 500 tests = make_suite(loaders, ['all']) 494 def build_test(test):501 def _build_test(test): 495 502 # In order for nosetest to show the test name, wrap the test.run_all 496 503 # instance in function that takes the test name as a parameter which … … 510 517 511 518 for test in tests: 512 yield build_test(test)519 yield _build_test(test) 513 520 514 521 … … 539 546 "models will be tested. See core.list_models() for " 540 547 "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": 544 551 if not use_opencl(): 545 552 print("opencl is not available") 546 553 return 1 547 554 loaders = ['opencl'] 548 elif args.engine == "dll":555 elif opts.engine == "dll": 549 556 loaders = ["dll"] 550 elif args.engine == "cuda":557 elif opts.engine == "cuda": 551 558 if not use_cuda(): 552 559 print("cuda is not available") 553 560 return 1 554 561 loaders = ['cuda'] 555 elif args.engine == "all":562 elif opts.engine == "all": 556 563 loaders = ['dll'] 557 564 if use_opencl(): … … 560 567 loaders.append('cuda') 561 568 else: 562 print("unknown engine " + args.engine)569 print("unknown engine " + opts.engine) 563 570 return 1 564 571 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)) 567 574 return 1 if result.failures or result.errors else 0 568 575
Note: See TracChangeset
for help on using the changeset viewer.