Changeset 0b03001 in sasmodels
- Timestamp:
- Jul 27, 2016 8:17:31 PM (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:
- 7f1ee79
- Parents:
- 6351bfa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
r0c24a82 r0b03001 57 57 # build_model 58 58 59 def list_models( ):59 def list_models(kind=None): 60 60 # type: () -> List[str] 61 61 """ 62 62 Return the list of available models on the model path. 63 63 """ 64 KINDS = ("all", "py", "c", "double", "oriented", "magnetic") 65 if kind and kind not in KINDS: 66 raise ValueError("kind not in "+", ".join(KINDS)) 64 67 root = dirname(__file__) 65 68 files = sorted(glob(joinpath(root, 'models', "[a-zA-Z]*.py"))) 66 69 available_models = [basename(f)[:-3] for f in files] 67 return available_models 70 selected = [name for name in available_models if _matches(name, kind)] 71 72 return selected 73 74 def _matches(name, kind): 75 if kind is None or kind=="all": 76 return True 77 info = load_model_info(name) 78 pars = info.parameters.kernel_parameters 79 if kind == "py" and callable(info.Iq): 80 return True 81 elif kind == "c" and not callable(info.Iq): 82 return True 83 elif kind == "double" and not info.single: 84 return True 85 elif kind == "oriented" and any(p.type=='orientation' for p in pars): 86 return True 87 elif kind == "magnetic" and any(p.type=='sld' for p in pars): 88 return True 89 return False 68 90 69 91 def load_model(model_name, dtype=None, platform='ocl'): … … 223 245 224 246 if __name__ == "__main__": 225 print("\n".join(list_models())) 247 import sys 248 kind = sys.argv[1] if len(sys.argv) > 1 else "all" 249 print("\n".join(list_models(kind)))
Note: See TracChangeset
for help on using the changeset viewer.