#NEWLINE# def resolve_fid( fid ) : #NEWLINE# #INDENT# '\n    Convert a given "function id" string to a number of list of numbers,\n    with the ability to resolve symbolic names for a variety of function\n    classes.\n\n    XXX: So far, the classes are fixed as determined on the scipy+CMA\n    portfolio. Instead, determine them dynamically.\n    ' #NEWLINE# if ( fid . count ( ',' ) > 0 ) : #NEWLINE# #INDENT# return [ int ( m ) for i in fid . split ( ',' ) ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return int ( fid ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# symbols = dict ( all = set ( range ( 1 , 25 ) ) , q = set ( [ 1 , 2 , 5 ] ) , single = set ( [ 2 , 3 , 4 , 6 , 7 , 10 , 11 , 12 , 13 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 ] ) , many = set ( [ 1 , 5 , 8 , 9 , 14 , 24 ] ) , volatile = set ( [ 6 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 19 , 20 , 21 , 22 , 23 , 24 ] ) , steady = set ( [ 6 , 12 , 17 , 18 , 19 , 24 ] ) , sudden = set ( [ 1 , 2 , 3 , 4 , 5 , 7 , 8 , 9 , 10 , 11 , 13 , 14 , 15 , 16 , 20 , 21 , 22 , 23 ] ) , CMAgood = set ( [ 6 , 7 , 10 , 11 , 12 , 13 , 16 , 17 , 18 , 21 , 22 , 23 ] ) , CMAbad = set ( [ 1 , 2 , 3 , 4 , 5 , 8 , 9 , 14 , 15 , 19 , 20 , 24 ] ) , separ = set ( range ( 1 , 6 ) ) , lcond = set ( range ( 6 , 10 ) ) , hcond = set ( range ( 10 , 15 ) ) , multi = set ( range ( 15 , 20 ) ) , mult2 = set ( range ( 20 , 25 ) ) ) #NEWLINE# fidset = set ( [ ] ) #NEWLINE# for m in re . finditer ( '([+:-])?([^+:-]+)' , fid ) : #NEWLINE# #INDENT# if ( m . group ( 1 ) is None ) : #NEWLINE# #INDENT# fidset = symbols [ m . group ( 2 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( m . group ( 1 ) == '+' ) : #NEWLINE# #INDENT# fidset |= symbols [ m . group ( 2 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( m . group ( 1 ) == ':' ) : #NEWLINE# #INDENT# fidset &= symbols [ m . group ( 2 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( m . group ( 1 ) == '-' ) : #NEWLINE# #INDENT# fidset -= symbols [ m . group ( 2 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'bad fid syntax ' + fid ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return list ( fidset )