Changes in sasmodels/compare.py [72a081d:af92b73] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r72a081d raf92b73 369 369 model = MultiplicationModel(P, S) 370 370 else: 371 raise ValueError(" sasview mixture models not supported by compare")371 raise ValueError("mixture models not handled yet") 372 372 else: 373 373 model = get_model(model_info['oldname']) … … 424 424 Return a model calculator using the OpenCL calculation engine. 425 425 """ 426 try: 427 model = core.build_model(model_info, dtype=dtype, platform="ocl") 428 except Exception as exc: 429 print(exc) 430 print("... trying again with single precision") 431 model = core.build_model(model_info, dtype='single', platform="ocl") 426 def builder(model_info): 427 try: 428 return core.build_model(model_info, dtype=dtype, platform="ocl") 429 except Exception as exc: 430 print(exc) 431 print("... trying again with single precision") 432 return core.build_model(model_info, dtype='single', platform="ocl") 433 if model_info['composition']: 434 composition_type, parts = model_info['composition'] 435 if composition_type == 'product': 436 P, S = [builder(p) for p in parts] 437 model = product.ProductModel(P, S) 438 else: 439 raise ValueError("mixture models not handled yet") 440 else: 441 model = builder(model_info) 432 442 calculator = DirectModel(data, model, cutoff=cutoff) 433 443 calculator.engine = "OCL%s"%DTYPE_MAP[dtype] … … 440 450 if dtype == 'quad': 441 451 dtype = 'longdouble' 442 model = core.build_model(model_info, dtype=dtype, platform="dll") 452 def builder(model_info): 453 return core.build_model(model_info, dtype=dtype, platform="dll") 454 455 if model_info['composition']: 456 composition_type, parts = model_info['composition'] 457 if composition_type == 'product': 458 P, S = [builder(p) for p in parts] 459 model = product.ProductModel(P, S) 460 else: 461 raise ValueError("mixture models not handled yet") 462 else: 463 model = builder(model_info) 443 464 calculator = DirectModel(data, model, cutoff=cutoff) 444 465 calculator.engine = "OMP%s"%DTYPE_MAP[dtype] … … 694 715 print("expected parameters: model N1 N2") 695 716 717 def _get_info(name): 718 try: 719 model_info = core.load_model_info(name) 720 except ImportError, exc: 721 print(str(exc)) 722 print("Use one of:\n " + models) 723 sys.exit(1) 724 return model_info 725 696 726 name = args[0] 697 try: 698 model_info = core.load_model_info(name) 699 except ImportError, exc: 700 print(str(exc)) 701 print("Could not find model; use one of:\n " + models) 702 sys.exit(1) 727 if '*' in name: 728 parts = [_get_info(k) for k in name.split('*')] 729 model_info = product.make_product_info(*parts) 730 else: 731 model_info = _get_info(name) 703 732 704 733 invalid = [o[1:] for o in flags … … 720 749 'res' : 0.0, 721 750 'accuracy' : 'Low', 722 'cutoff' : 0.0,751 'cutoff' : 1e-5, 723 752 'seed' : -1, # default to preset 724 753 'mono' : False,
Note: See TracChangeset
for help on using the changeset viewer.