- Timestamp:
- 07/25/15 19:01:20 (10 months ago)
- Location:
- mystic/mystic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/mystic/scripts.py
r807 r810 418 418 #XXX: note that 'argparse' is new as of python2.7 419 419 from optparse import OptionParser 420 def _exit(self, **kwds):420 def _exit(self, errno=None, msg=None): 421 421 global __quit 422 422 __quit = True 423 if errno or msg: 424 msg = msg.split(': error: ')[-1].strip() 425 raise IOError(msg) 423 426 OptionParser.exit = _exit 424 427 … … 456 459 parser.add_option("-j","--join",action="store_true",dest="line",\ 457 460 default=False,help="connect trajectory points in plot") 458 parsed_opts, parsed_args = parser.parse_args(cmdargs)459 461 460 462 # import sys … … 468 470 f.close() 469 471 472 try: 473 parsed_opts, parsed_args = parser.parse_args(cmdargs) 474 except UnboundLocalError: 475 pass 470 476 if __quit: return 471 477 … … 696 702 #XXX: note that 'argparse' is new as of python2.7 697 703 from optparse import OptionParser 698 def _exit(self, **kwds):704 def _exit(self, errno=None, msg=None): 699 705 global __quit 700 706 __quit = True 707 if errno or msg: 708 msg = msg.split(': error: ')[-1].strip() 709 raise IOError(msg) 701 710 OptionParser.exit = _exit 702 711 … … 721 730 #parser.add_option("-f","--file",action="store",dest="filename",metavar="FILE",\ 722 731 # default='log.txt',help="log file name") 723 parsed_opts, parsed_args = parser.parse_args(cmdargs)724 732 725 733 # import sys … … 733 741 f.close() 734 742 743 try: 744 parsed_opts, parsed_args = parser.parse_args(cmdargs) 745 except UnboundLocalError: 746 pass 747 if __quit: return 748 735 749 style = '-' # default linestyle 736 750 if parsed_opts.dots: … … 742 756 mark = '' 743 757 744 if __quit: return745 746 758 try: # get logfile name 747 759 filename = parsed_args[0] 748 760 except: 749 raise IOError , "please provide log file name"761 raise IOError("please provide log file name") 750 762 751 763 try: # select which iteration to stop plotting at -
mystic/mystic/support.py
r809 r810 339 339 #XXX: note that 'argparse' is new as of python2.7 340 340 from optparse import OptionParser 341 def _exit(self, **kwds):341 def _exit(self, errno=None, msg=None): 342 342 global __quit 343 343 __quit = True 344 if errno or msg: 345 msg = msg.split(': error: ')[-1].strip() 346 raise IOError(msg) 344 347 OptionParser.exit = _exit 345 348 … … 363 366 parser.add_option("-g","--legend",action="store_true",dest="legend",\ 364 367 default=False,help="show the legend") 365 parsed_opts, parsed_args = parser.parse_args(cmdargs)366 368 367 369 from StringIO import StringIO … … 373 375 f.close() 374 376 377 try: 378 parsed_opts, parsed_args = parser.parse_args(cmdargs) 379 except UnboundLocalError: 380 pass 375 381 if __quit: return 376 382 … … 572 578 #XXX: note that 'argparse' is new as of python2.7 573 579 from optparse import OptionParser 574 def _exit(self, **kwds):580 def _exit(self, errno=None, msg=None): 575 581 global __quit 576 582 __quit = True 583 if errno or msg: 584 msg = msg.split(': error: ')[-1].strip() 585 raise IOError(msg) 577 586 OptionParser.exit = _exit 578 587 … … 601 610 parser.add_option("-f","--flat",action="store_true",dest="flatten",\ 602 611 default=False,help="show selected iterations in a single plot") 603 parsed_opts, parsed_args = parser.parse_args(cmdargs)604 612 605 613 from StringIO import StringIO … … 611 619 f.close() 612 620 621 try: 622 parsed_opts, parsed_args = parser.parse_args(cmdargs) 623 except UnboundLocalError: 624 pass 613 625 if __quit: return 614 626 … … 664 676 for bound in bounds: 665 677 if not isinstance(bound, tuple): 666 raise TypeError , "bounds should be tuples of (lower_bound,upper_bound)"678 raise TypeError("bounds should be tuples of (lower_bound,upper_bound)") 667 679 for i in range(len(xyz)): 668 680 if isinstance(xyz[i], int): 669 681 xyz[i] = (xyz[i],) 670 682 elif not isinstance(xyz[i], tuple): 671 raise TypeError , "xyz should be tuples of (param1,param2,param3,...)"683 raise TypeError("xyz should be tuples of (param1,param2,param3,...)") 672 684 673 685 # ensure all terms of select are strings that have a ":" … … 848 860 #XXX: note that 'argparse' is new as of python2.7 849 861 from optparse import OptionParser 850 def _exit(self, **kwds):862 def _exit(self, errno=None, msg=None): 851 863 global __quit 852 864 __quit = True 865 if errno or msg: 866 msg = msg.split(': error: ')[-1].strip() 867 raise IOError(msg) 853 868 OptionParser.exit = _exit 854 869 … … 880 895 parser.add_option("-f","--flat",action="store_true",dest="flatten",\ 881 896 default=False,help="show selected iterations in a single plot") 882 parsed_opts, parsed_args = parser.parse_args(cmdargs)883 897 884 898 from StringIO import StringIO … … 890 904 f.close() 891 905 906 try: 907 parsed_opts, parsed_args = parser.parse_args(cmdargs) 908 except UnboundLocalError: 909 pass 892 910 if __quit: return 893 911 … … 945 963 for bound in bounds: 946 964 if not isinstance(bound, tuple): 947 raise TypeError , "bounds should be tuples of (lower_bound,upper_bound)"965 raise TypeError("bounds should be tuples of (lower_bound,upper_bound)") 948 966 for i in range(len(xyz)): 949 967 if isinstance(xyz[i], int): 950 968 xyz[i] = (xyz[i],) 951 969 elif not isinstance(xyz[i], tuple): 952 raise TypeError , "xyz should be tuples of (param1,param2,param3,...)"970 raise TypeError("xyz should be tuples of (param1,param2,param3,...)") 953 971 for i in range(len(wxyz)): 954 972 if isinstance(wxyz[i], int): 955 973 wxyz[i] = (wxyz[i],) 956 974 elif not isinstance(wxyz[i], tuple): 957 raise TypeError , "wxyz should be tuples of (param1,param2,param3,...)"975 raise TypeError("wxyz should be tuples of (param1,param2,param3,...)") 958 976 959 977 # ensure all terms of select are strings of ints … … 961 979 if isinstance(select[i], int): select[i] = str(select[i]) 962 980 if select[i].count(':'): 963 raise ValueError , "iters should be ints"981 raise ValueError("iters should be ints") 964 982 #if select[i] == '-1': select[i] = 'len(x)-1:len(x)' 965 983 #elif not select[i].count(':'): … … 1060 1078 t[v].append([str((1.0 - i[q]*j[q]*k[q])**scale) for q in range(len(i))]) 1061 1079 if float(t[v][-1][-1]) > 1.0 or float(t[v][-1][-1]) < 0.0: 1062 raise ValueError , "Weights must be in range 0-1. Check normalization and/or assignment."1080 raise ValueError("Weights must be in range 0-1. Check normalization and/or assignment.") 1063 1081 1064 1082 # build all the plots … … 1165 1183 #XXX: note that 'argparse' is new as of python2.7 1166 1184 from optparse import OptionParser 1167 def _exit(self, **kwds):1185 def _exit(self, errno=None, msg=None): 1168 1186 global __quit 1169 1187 __quit = True 1188 if errno or msg: 1189 msg = msg.split(': error: ')[-1].strip() 1190 raise IOError(msg) 1170 1191 OptionParser.exit = _exit 1171 1192 … … 1209 1230 parser.add_option("-f","--flat",action="store_true",dest="flatten",\ 1210 1231 default=False,help="show selected iterations in a single plot") 1211 parsed_opts, parsed_args = parser.parse_args(cmdargs)1212 1232 1213 1233 from StringIO import StringIO … … 1219 1239 f.close() 1220 1240 1241 try: 1242 parsed_opts, parsed_args = parser.parse_args(cmdargs) 1243 except UnboundLocalError: 1244 pass 1221 1245 if __quit: return 1222 1246 … … 1259 1283 data = load_dataset(file, filter) 1260 1284 except: 1261 # raise IOError , "please provide dataset file name"1285 # raise IOError("please provide dataset file name") 1262 1286 data = dataset() 1263 1287 cones = False … … 1338 1362 for bound in bounds: 1339 1363 if not isinstance(bound, tuple): 1340 raise TypeError , "bounds should be tuples of (lower_bound,upper_bound)"1364 raise TypeError("bounds should be tuples of (lower_bound,upper_bound)") 1341 1365 1342 1366 # ensure all terms of select are strings that have a ":"
Note: See TracChangeset
for help on using the changeset viewer.