Changeset 72be531 in sasmodels
- Timestamp:
- Jul 26, 2017 3:37:05 PM (7 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 0bdddc2
- Parents:
- d1ff3a5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/list_pars.py
r3330bb4 r72be531 12 12 13 13 import sys 14 import argparse 14 15 15 16 from .core import load_model_info, list_models 16 17 from .compare import columnize 17 18 18 def find_pars( ):19 def find_pars(type=None): 19 20 """ 20 21 Find all parameters in all models. … … 26 27 model_info = load_model_info(name) 27 28 for p in model_info.parameters.kernel_parameters: 28 partable.setdefault(p.name, []) 29 partable[p.name].append(name) 29 if type is None or p.type == type: 30 partable.setdefault(p.name, []) 31 partable[p.name].append(name) 30 32 return partable 31 33 32 def list_pars(names_only=True ):34 def list_pars(names_only=True, type=None): 33 35 """ 34 36 Print all parameters in all models. … … 37 39 occurs in. 38 40 """ 39 partable = find_pars( )41 partable = find_pars(type) 40 42 if names_only: 41 43 print(columnize(list(sorted(partable.keys())))) … … 48 50 Program to list the parameters used across all models. 49 51 """ 50 if len(sys.argv) == 2 and sys.argv[1] == '-v': 51 verbose = True 52 elif len(sys.argv) == 1: 53 verbose = False 54 else: 55 print(__doc__) 56 sys.exit(1) 57 list_pars(names_only=not verbose) 52 parser = argparse.ArgumentParser( 53 description="Find all parameters in all models", 54 ) 55 parser.add_argument( 56 '-v', '--verbose', 57 action='store_true', 58 help="list models which use this argument") 59 parser.add_argument( 60 'type', default="any", nargs='?', 61 metavar="volume|orientation|sld|none|any", 62 choices=['volume', 'orientation', 'sld', None, 'any'], 63 type=lambda v: None if v == 'any' else '' if v == 'none' else v, 64 help="only list arguments of the given type") 65 args = parser.parse_args() 66 67 list_pars(names_only=not args.verbose, type=args.type) 58 68 59 69 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.