core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change
on this file since 1d4017a was
1d4017a,
checked in by Paul Kienzle <pkienzle@…>, 8 years ago
|
add command for list all parameters in all models
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | """ |
---|
2 | List all parameters used along with the models which use them. |
---|
3 | |
---|
4 | Usage: |
---|
5 | |
---|
6 | python -m sasmodels.list_pars [-v] |
---|
7 | |
---|
8 | If '-v' is given, then list the models containing the parameter in |
---|
9 | addition to just the parameter name. |
---|
10 | """ |
---|
11 | import sys |
---|
12 | |
---|
13 | from .core import load_model_definition |
---|
14 | from .generate import make_info |
---|
15 | from .compare import MODELS, columnize |
---|
16 | |
---|
17 | def find_pars(): |
---|
18 | partable = {} |
---|
19 | for name in sorted(MODELS): |
---|
20 | definition = load_model_definition(name) |
---|
21 | info = make_info(definition) |
---|
22 | for p in info['parameters']: |
---|
23 | pname = p[0] |
---|
24 | partable.setdefault(pname, []) |
---|
25 | partable[pname].append(name) |
---|
26 | return partable |
---|
27 | |
---|
28 | def list_pars(names_only=True): |
---|
29 | partable = find_pars() |
---|
30 | if names_only: |
---|
31 | print(columnize(list(sorted(partable.keys())))) |
---|
32 | else: |
---|
33 | for k,v in sorted(partable.items()): |
---|
34 | print("%s: %s"%(k, ", ".join(v))) |
---|
35 | |
---|
36 | def main(): |
---|
37 | if len(sys.argv) == 2 and sys.argv[1] == '-v': |
---|
38 | verbose = True |
---|
39 | elif len(sys.argv) == 1: |
---|
40 | verbose = False |
---|
41 | else: |
---|
42 | print(__doc__) |
---|
43 | sys.exit(1) |
---|
44 | list_pars(names_only=not verbose) |
---|
45 | |
---|
46 | if __name__ == "__main__": |
---|
47 | main() |
---|
Note: See
TracBrowser
for help on using the repository browser.