Changeset d92182f in sasmodels for sasmodels/model_test.py
- Timestamp:
- Mar 11, 2019 9:30:49 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:
- d8eaa3d
- Parents:
- aee8dfb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/model_test.py
raee8dfb rd92182f 5 5 Usage:: 6 6 7 python -m sasmodels.model_test [opencl|cuda|dll] model1 model2 ... 8 9 if model1 is 'all', then all except the remaining models will be tested 7 python -m sasmodels.model_test [opencl|cuda|dll|all] model1 model2 ... 8 9 If model1 is 'all', then all except the remaining models will be tested. 10 Subgroups are also possible, such as 'py', 'single' or '1d'. See 11 :func:`core.list_models` for details. 10 12 11 13 Each model is tested using the default parameters at q=0.1, (qx, qy)=(0.1, 0.1), … … 90 92 suite = unittest.TestSuite() 91 93 92 if models[0] in core.KINDS: 94 try: 95 # See if the first model parses as a model group 96 group = list_models(models[0]) 93 97 skip = models[1:] 94 models = list_models(models[0])95 e lse:98 models = group 99 except Exception: 96 100 skip = [] 97 101 for model_name in models: … … 475 479 476 480 477 def main():478 # type: (*str) -> int479 """480 Run tests given is models.481 482 Returns 0 if success or 1 if any tests fail.483 """484 try:485 from xmlrunner import XMLTestRunner as TestRunner486 test_args = {'output': 'logs'}487 except ImportError:488 from unittest import TextTestRunner as TestRunner489 test_args = {}490 491 parser = argparse.ArgumentParser(description="Test SasModels Models")492 parser.add_argument("-v", "--verbose", action="store_const",493 default=1, const=2, help="Use verbose output")494 parser.add_argument("engine", metavar="[engine]",495 help="Engines on which to run the test. "496 "Valid values are opencl, dll, and opencl_and_dll. "497 "Defaults to opencl_and_dll if no value is given")498 parser.add_argument("models", nargs="*",499 help='The names of the models to be tested. '500 'If the first model is "all", then all except the '501 'remaining models will be tested.')502 args, models = parser.parse_known_args()503 504 if args.engine == "opencl":505 if not use_opencl():506 print("opencl is not available")507 return 1508 loaders = ['opencl']509 elif args.engine == "dll":510 loaders = ["dll"]511 elif args.engine == "cuda":512 if not use_cuda():513 print("cuda is not available")514 return 1515 loaders = ['cuda']516 else:517 # Default to running both engines518 loaders = ['dll']519 if use_opencl():520 loaders.append('opencl')521 if use_cuda():522 loaders.append('cuda')523 args.models.insert(0, args.engine)524 525 runner = TestRunner(verbosity=args.verbose, **test_args)526 result = runner.run(make_suite(loaders, args.models))527 return 1 if result.failures or result.errors else 0528 529 530 481 def model_tests(): 531 482 # type: () -> Iterator[Callable[[], None]] … … 562 513 563 514 515 def main(): 516 # type: (*str) -> int 517 """ 518 Run tests given is models. 519 520 Returns 0 if success or 1 if any tests fail. 521 """ 522 try: 523 from xmlrunner import XMLTestRunner as TestRunner 524 test_args = {'output': 'logs'} 525 except ImportError: 526 from unittest import TextTestRunner as TestRunner 527 test_args = {} 528 529 parser = argparse.ArgumentParser(description="Test SasModels Models") 530 parser.add_argument("-v", "--verbose", action="store_const", 531 default=1, const=2, help="Use verbose output") 532 parser.add_argument("-e", "--engine", default="all", 533 help="Engines on which to run the test. " 534 "Valid values are opencl, cuda, dll, and all. " 535 "Defaults to all if no value is given") 536 parser.add_argument("models", nargs="*", 537 help="The names of the models to be tested. " 538 "If the first model is 'all', then all but the listed " 539 "models will be tested. See core.list_models() for " 540 "names of other groups, such as 'py' or 'single'.") 541 args, models = parser.parse_known_args() 542 543 if args.engine == "opencl": 544 if not use_opencl(): 545 print("opencl is not available") 546 return 1 547 loaders = ['opencl'] 548 elif args.engine == "dll": 549 loaders = ["dll"] 550 elif args.engine == "cuda": 551 if not use_cuda(): 552 print("cuda is not available") 553 return 1 554 loaders = ['cuda'] 555 elif args.engine == "all": 556 loaders = ['dll'] 557 if use_opencl(): 558 loaders.append('opencl') 559 if use_cuda(): 560 loaders.append('cuda') 561 else: 562 print("unknown engine " + args.engine) 563 return 1 564 565 runner = TestRunner(verbosity=args.verbose, **test_args) 566 result = runner.run(make_suite(loaders, args.models)) 567 return 1 if result.failures or result.errors else 0 568 569 564 570 if __name__ == "__main__": 565 571 sys.exit(main())
Note: See TracChangeset
for help on using the changeset viewer.