Changeset 2547694 in sasmodels
- Timestamp:
- Jul 28, 2016 8:23:10 AM (8 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified sasmodels/core.py ¶
rd2d6100 r2547694 6 6 __all__ = [ 7 7 "list_models", "load_model", "load_model_info", 8 "build_model", "precompile_dll ",8 "build_model", "precompile_dlls", 9 9 ] 10 10 11 11 import os 12 from os.path import basename, dirname, join as joinpath , splitext12 from os.path import basename, dirname, join as joinpath 13 13 from glob import glob 14 14 … … 57 57 # build_model 58 58 59 KINDS = ("all", "py", "c", "double", "single", "1d", "2d", 60 "nonmagnetic", "magnetic") 59 61 def list_models(kind=None): 60 62 # type: () -> List[str] … … 62 64 Return the list of available models on the model path. 63 65 """ 64 KINDS = ("all", "py", "c", "double", "single", "1d", "2d", "nonmagnetic", "magnetic")65 66 if kind and kind not in KINDS: 66 raise ValueError("kind not in " +", ".join(KINDS))67 raise ValueError("kind not in " + ", ".join(KINDS)) 67 68 root = dirname(__file__) 68 69 files = sorted(glob(joinpath(root, 'models', "[a-zA-Z]*.py"))) … … 73 74 74 75 def _matches(name, kind): 75 if kind is None or kind =="all":76 if kind is None or kind == "all": 76 77 return True 77 78 info = load_model_info(name) … … 85 86 elif kind == "single" and info.single: 86 87 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): 94 95 return True 95 96 return False … … 157 158 return mixture.MixtureModel(model_info, models) 158 159 elif composition_type == 'product': 159 from . import product160 160 P, S = models 161 161 return product.ProductModel(model_info, P, S) … … 217 217 if platform is None: 218 218 platform = "ocl" 219 if platform =="ocl" and not HAVE_OPENCL:219 if platform == "ocl" and not HAVE_OPENCL: 220 220 platform = "dll" 221 221 … … 226 226 227 227 # Convert special type names "half", "fast", and "quad" 228 fast = (dtype =="fast")228 fast = (dtype == "fast") 229 229 if fast: 230 230 dtype = "single" 231 elif dtype =="quad":231 elif dtype == "quad": 232 232 dtype = "longdouble" 233 elif dtype =="half":233 elif dtype == "half": 234 234 dtype = "f16" 235 235 236 236 # Convert dtype string to numpy dtype. 237 237 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) 239 240 else: 240 241 numpy_dtype = np.dtype(dtype) 241 242 242 243 # Make sure that the type is supported by opencl, otherwise use dll 243 if platform =="ocl":244 if platform == "ocl": 244 245 env = kernelcl.environment() 245 246 if not env.has_type(numpy_dtype): … … 250 251 return numpy_dtype, fast, platform 251 252 252 if __name__ == "__main__":253 def list_models_main(): 253 254 import sys 254 255 kind = sys.argv[1] if len(sys.argv) > 1 else "all" 255 256 print("\n".join(list_models(kind))) 257 258 if __name__ == "__main__": 259 list_models_main()
Note: See TracChangeset
for help on using the changeset viewer.