Changeset 424fe00 in sasmodels
- Timestamp:
- Sep 12, 2016 1:17:05 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:
- 2a0c7a6
- Parents:
- 52ec91e
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sascomp
r6708a6a r424fe00 19 19 20 20 import sasmodels.compare 21 sasmodels.compare.main( )21 sasmodels.compare.main(*sys.argv[1:]) 22 22 23 23 if __name__ == "__main__": -
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:]) -
sasmodels/compare_many.py
r40a87fa r424fe00 229 229 print_models() 230 230 231 def main( ):231 def main(argv): 232 232 """ 233 233 Main program. 234 234 """ 235 if len( sys.argv) not in (6, 7):235 if len(argv) not in (5, 6): 236 236 print_help() 237 sys.exit(1)238 239 model = sys.argv[1]237 return 238 239 model = argv[0] 240 240 if not (model in MODELS) and (model != "all"): 241 241 print('Bad model %s. Use "all" or one of:'%model) 242 242 print_models() 243 sys.exit(1)243 return 244 244 try: 245 count = int( sys.argv[2])246 is2D = sys.argv[3].startswith('2d')247 assert sys.argv[3][1] == 'd'248 Nq = int( sys.argv[3][2:])249 mono = sys.argv[4] == 'mono'250 cutoff = float( sys.argv[4]) if not mono else 0251 base = sys.argv[5]252 comp = sys.argv[6] if len(sys.argv) > 6else "sasview"245 count = int(argv[1]) 246 is2D = argv[2].startswith('2d') 247 assert argv[2][1] == 'd' 248 Nq = int(argv[2][2:]) 249 mono = argv[3] == 'mono' 250 cutoff = float(argv[3]) if not mono else 0 251 base = argv[4] 252 comp = argv[5] if len(argv) > 5 else "sasview" 253 253 except Exception: 254 254 traceback.print_exc() 255 255 print_usage() 256 sys.exit(1)256 return 257 257 258 258 data, index = make_data({'qmax':1.0, 'is2d':is2D, 'nq':Nq, 'res':0., … … 265 265 if __name__ == "__main__": 266 266 #from .compare import push_seed 267 #with push_seed(1): main( )268 main( )267 #with push_seed(1): main(sys.argv[1:]) 268 main(sys.argv[1:])
Note: See TracChangeset
for help on using the changeset viewer.