Changeset 424fe00 in sasmodels for sasmodels/compare.py
- Timestamp:
- Sep 11, 2016 11:17:05 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:
- 2a0c7a6
- Parents:
- 52ec91e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
ra557a99 r424fe00 777 777 778 778 779 def parse_opts( ):780 # type: ( ) -> Dict[str, Any]779 def parse_opts(argv): 780 # type: (List[str]) -> Dict[str, Any] 781 781 """ 782 782 Parse command line options. 783 783 """ 784 784 MODELS = core.list_models() 785 flags = [arg for arg in sys.argv[1:]785 flags = [arg for arg in argv 786 786 if arg.startswith('-')] 787 values = [arg for arg in sys.argv[1:]787 values = [arg for arg in argv 788 788 if not arg.startswith('-') and '=' in arg] 789 args = [arg for arg in sys.argv[1:]789 positional_args = [arg for arg in argv 790 790 if not arg.startswith('-') and '=' not in arg] 791 791 models = "\n ".join("%-15s"%v for v in MODELS) 792 if len( args) == 0:792 if len(positional_args) == 0: 793 793 print(USAGE) 794 794 print("\nAvailable models:") 795 795 print(columnize(MODELS, indent=" ")) 796 sys.exit(1)797 if len( args) > 3:796 return None 797 if len(positional_args) > 3: 798 798 print("expected parameters: model N1 N2") 799 799 800 name = args[0]800 name = positional_args[0] 801 801 try: 802 802 model_info = core.load_model_info(name) … … 804 804 print(str(exc)) 805 805 print("Could not find model; use one of:\n " + models) 806 sys.exit(1)806 return None 807 807 808 808 invalid = [o[1:] for o in flags … … 811 811 if invalid: 812 812 print("Invalid options: %s"%(", ".join(invalid))) 813 sys.exit(1)813 return None 814 814 815 815 … … 886 886 del engines[2:] 887 887 888 n1 = int( args[1]) if len(args) > 1 else 1889 n2 = int( args[2]) if len(args) > 2 else 1888 n1 = int(positional_args[1]) if len(positional_args) > 1 else 1 889 n2 = int(positional_args[2]) if len(positional_args) > 2 else 1 890 890 use_sasview = any(engine == 'sasview' and count > 0 891 891 for engine, count in zip(engines, [n1, n2])) … … 904 904 s = set(p.split('_pd')[0] for p in pars) 905 905 print("%r invalid; parameters are: %s"%(k, ", ".join(sorted(s)))) 906 sys.exit(1)906 return None 907 907 presets[k] = float(v) if not k.endswith('type') else v 908 908 … … 1036 1036 1037 1037 1038 def main( ):1039 # type: ( ) -> None1038 def main(*argv): 1039 # type: (*str) -> None 1040 1040 """ 1041 1041 Main program. 1042 1042 """ 1043 opts = parse_opts() 1044 if opts['explore']: 1045 explore(opts) 1046 else: 1047 compare(opts) 1043 opts = parse_opts(argv) 1044 if opts is not None: 1045 if opts['explore']: 1046 explore(opts) 1047 else: 1048 compare(opts) 1048 1049 1049 1050 if __name__ == "__main__": 1050 main( )1051 main(*sys.argv[1:])
Note: See TracChangeset
for help on using the changeset viewer.