diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-08-18 11:51:25 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-08-18 11:51:25 -0600 |
commit | fbd6510d58a47ea0d166c48a82793f05425406e4 (patch) | |
tree | 330ce703eb02d20f96099c3fe0fc36ae33d4905b /numpy/f2py/auxfuncs.py | |
parent | 8ddb0ce0acafe75d78df528b4d2540dfbf4b364d (diff) | |
download | numpy-fbd6510d58a47ea0d166c48a82793f05425406e4.tar.gz |
STY: Giant comma spacing fixup.
Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long
and will need to be broken at some point. OTOH, some lines were already
too long and need to be broken at some point. Now seems as good a time
as any to do this with open PRs at a minimum.
Diffstat (limited to 'numpy/f2py/auxfuncs.py')
-rw-r--r-- | numpy/f2py/auxfuncs.py | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/numpy/f2py/auxfuncs.py b/numpy/f2py/auxfuncs.py index e835090f7..2e016e186 100644 --- a/numpy/f2py/auxfuncs.py +++ b/numpy/f2py/auxfuncs.py @@ -37,7 +37,7 @@ wrapfuncs = 1 def outmess(t): - if options.get('verbose',1): + if options.get('verbose', 1): sys.stdout.write(t) def debugcapi(var): @@ -68,7 +68,7 @@ def isscalar(var): return not (isarray(var) or isstring(var) or isexternal(var)) def iscomplex(var): - return isscalar(var) and var.get('typespec') in ['complex','double complex'] + return isscalar(var) and var.get('typespec') in ['complex', 'double complex'] def islogical(var): return isscalar(var) and var.get('typespec')=='logical' @@ -91,7 +91,7 @@ def get_kind(var): def islong_long(var): if not isscalar(var): return 0 - if var.get('typespec') not in ['integer','logical']: + if var.get('typespec') not in ['integer', 'logical']: return 0 return get_kind(var)=='8' @@ -143,7 +143,7 @@ def islong_complex(var): return get_kind(var)=='32' def iscomplexarray(var): - return isarray(var) and var.get('typespec') in ['complex','double complex'] + return isarray(var) and var.get('typespec') in ['complex', 'double complex'] def isint1array(var): return isarray(var) and var.get('typespec')=='integer' \ @@ -216,7 +216,7 @@ def hasassumedshape(rout): if rout.get('hasassumedshape'): return True for a in rout['args']: - for d in rout['vars'].get(a,{}).get('dimension',[]): + for d in rout['vars'].get(a, {}).get('dimension', []): if d==':': rout['hasassumedshape'] = True return True @@ -332,53 +332,53 @@ def isintent_inout(var): return 'intent' in var and ('inout' in var['intent'] or 'outin' in var['intent']) and 'in' not in var['intent'] and 'hide' not in var['intent'] and 'inplace' not in var['intent'] def isintent_out(var): - return 'out' in var.get('intent',[]) + return 'out' in var.get('intent', []) def isintent_hide(var): - return ('intent' in var and ('hide' in var['intent'] or ('out' in var['intent'] and 'in' not in var['intent'] and (not l_or(isintent_inout,isintent_inplace)(var))))) + return ('intent' in var and ('hide' in var['intent'] or ('out' in var['intent'] and 'in' not in var['intent'] and (not l_or(isintent_inout, isintent_inplace)(var))))) def isintent_nothide(var): return not isintent_hide(var) def isintent_c(var): - return 'c' in var.get('intent',[]) + return 'c' in var.get('intent', []) # def isintent_f(var): # return not isintent_c(var) def isintent_cache(var): - return 'cache' in var.get('intent',[]) + return 'cache' in var.get('intent', []) def isintent_copy(var): - return 'copy' in var.get('intent',[]) + return 'copy' in var.get('intent', []) def isintent_overwrite(var): - return 'overwrite' in var.get('intent',[]) + return 'overwrite' in var.get('intent', []) def isintent_callback(var): - return 'callback' in var.get('intent',[]) + return 'callback' in var.get('intent', []) def isintent_inplace(var): - return 'inplace' in var.get('intent',[]) + return 'inplace' in var.get('intent', []) def isintent_aux(var): - return 'aux' in var.get('intent',[]) + return 'aux' in var.get('intent', []) def isintent_aligned4(var): - return 'aligned4' in var.get('intent',[]) + return 'aligned4' in var.get('intent', []) def isintent_aligned8(var): - return 'aligned8' in var.get('intent',[]) + return 'aligned8' in var.get('intent', []) def isintent_aligned16(var): - return 'aligned16' in var.get('intent',[]) - -isintent_dict = {isintent_in:'INTENT_IN',isintent_inout:'INTENT_INOUT', - isintent_out:'INTENT_OUT',isintent_hide:'INTENT_HIDE', - isintent_cache:'INTENT_CACHE', - isintent_c:'INTENT_C',isoptional:'OPTIONAL', - isintent_inplace:'INTENT_INPLACE', - isintent_aligned4:'INTENT_ALIGNED4', - isintent_aligned8:'INTENT_ALIGNED8', - isintent_aligned16:'INTENT_ALIGNED16', + return 'aligned16' in var.get('intent', []) + +isintent_dict = {isintent_in: 'INTENT_IN', isintent_inout: 'INTENT_INOUT', + isintent_out: 'INTENT_OUT', isintent_hide: 'INTENT_HIDE', + isintent_cache: 'INTENT_CACHE', + isintent_c: 'INTENT_C', isoptional: 'OPTIONAL', + isintent_inplace: 'INTENT_INPLACE', + isintent_aligned4: 'INTENT_ALIGNED4', + isintent_aligned8: 'INTENT_ALIGNED8', + isintent_aligned16: 'INTENT_ALIGNED16', } def isprivate(var): @@ -390,7 +390,7 @@ def hasinitvalue(var): def hasinitvalueasstring(var): if not hasinitvalue(var): return 0 - return var['='][0] in ['"',"'"] + return var['='][0] in ['"', "'"] def hasnote(var): return 'note' in var @@ -444,25 +444,25 @@ class F2PYError(Exception): pass class throw_error: - def __init__(self,mess): + def __init__(self, mess): self.mess = mess - def __call__(self,var): - mess = '\n\n var = %s\n Message: %s\n' % (var,self.mess) + def __call__(self, var): + mess = '\n\n var = %s\n Message: %s\n' % (var, self.mess) raise F2PYError(mess) def l_and(*f): - l,l2='lambda v',[] + l, l2='lambda v', [] for i in range(len(f)): - l='%s,f%d=f[%d]'%(l,i,i) + l='%s,f%d=f[%d]'%(l, i, i) l2.append('f%d(v)'%(i)) - return eval('%s:%s'%(l,' and '.join(l2))) + return eval('%s:%s'%(l, ' and '.join(l2))) def l_or(*f): - l,l2='lambda v',[] + l, l2='lambda v', [] for i in range(len(f)): - l='%s,f%d=f[%d]'%(l,i,i) + l='%s,f%d=f[%d]'%(l, i, i) l2.append('f%d(v)'%(i)) - return eval('%s:%s'%(l,' or '.join(l2))) + return eval('%s:%s'%(l, ' or '.join(l2))) def l_not(f): return eval('lambda v,f=f:not f(v)') @@ -508,22 +508,22 @@ def getmultilineblock(rout,blockname,comment=1,counter=0): r = r[:-3] else: errmess("%s multiline block should end with `'''`: %s\n" \ - % (blockname,repr(r))) + % (blockname, repr(r))) return r def getcallstatement(rout): - return getmultilineblock(rout,'callstatement') + return getmultilineblock(rout, 'callstatement') def getcallprotoargument(rout,cb_map={}): - r = getmultilineblock(rout,'callprotoargument',comment=0) + r = getmultilineblock(rout, 'callprotoargument', comment=0) if r: return r if hascallstatement(rout): outmess('warning: callstatement is defined without callprotoargument\n') return from .capi_maps import getctype - arg_types,arg_types2 = [],[] - if l_and(isstringfunction,l_not(isfunction_wrap))(rout): - arg_types.extend(['char*','size_t']) + arg_types, arg_types2 = [], [] + if l_and(isstringfunction, l_not(isfunction_wrap))(rout): + arg_types.extend(['char*', 'size_t']) for n in rout['args']: var = rout['vars'][n] if isintent_callback(var): @@ -532,7 +532,7 @@ def getcallprotoargument(rout,cb_map={}): ctype = cb_map[n]+'_typedef' else: ctype = getctype(var) - if l_and(isintent_c,l_or(isscalar,iscomplex))(var): + if l_and(isintent_c, l_or(isscalar, iscomplex))(var): pass elif isstring(var): pass @@ -550,16 +550,16 @@ def getcallprotoargument(rout,cb_map={}): return proto_args def getusercode(rout): - return getmultilineblock(rout,'usercode') + return getmultilineblock(rout, 'usercode') def getusercode1(rout): - return getmultilineblock(rout,'usercode',counter=1) + return getmultilineblock(rout, 'usercode', counter=1) def getpymethoddef(rout): - return getmultilineblock(rout,'pymethoddef') + return getmultilineblock(rout, 'pymethoddef') def getargs(rout): - sortargs,args=[],[] + sortargs, args=[], [] if 'args' in rout: args=rout['args'] if 'sortvars' in rout: @@ -569,10 +569,10 @@ def getargs(rout): if a not in sortargs: sortargs.append(a) else: sortargs=rout['args'] - return args,sortargs + return args, sortargs def getargs2(rout): - sortargs,args=[],rout.get('args',[]) + sortargs, args=[], rout.get('args', []) auxvars = [a for a in rout['vars'].keys() if isintent_aux(rout['vars'][a])\ and a not in args] args = auxvars + args @@ -583,23 +583,23 @@ def getargs2(rout): if a not in sortargs: sortargs.append(a) else: sortargs=auxvars + rout['args'] - return args,sortargs + return args, sortargs def getrestdoc(rout): if 'f2pymultilines' not in rout: return None k = None if rout['block']=='python module': - k = rout['block'],rout['name'] - return rout['f2pymultilines'].get(k,None) + k = rout['block'], rout['name'] + return rout['f2pymultilines'].get(k, None) def gentitle(name): l=(80-len(name)-6)//2 - return '/*%s %s %s*/'%(l*'*',name,l*'*') + return '/*%s %s %s*/'%(l*'*', name, l*'*') def flatlist(l): if isinstance(l, list): - return reduce(lambda x,y,f=flatlist:x+f(y),l,[]) + return reduce(lambda x,y,f=flatlist:x+f(y), l, []) return [l] def stripcomma(s): @@ -619,15 +619,15 @@ def replace(str,d,defaultsep=''): else: sep=defaultsep if isinstance(d[k], list): - str=str.replace('#%s#'%(k),sep.join(flatlist(d[k]))) + str=str.replace('#%s#'%(k), sep.join(flatlist(d[k]))) else: - str=str.replace('#%s#'%(k),d[k]) + str=str.replace('#%s#'%(k), d[k]) return str -def dictappend(rd,ar): +def dictappend(rd, ar): if isinstance(ar, list): for a in ar: - rd=dictappend(rd,a) + rd=dictappend(rd, a) return rd for k in ar.keys(): if k[0]=='_': @@ -647,7 +647,7 @@ def dictappend(rd,ar): if k1 not in rd[k]: rd[k][k1]=ar[k][k1] else: - rd[k]=dictappend(rd[k],ar[k]) + rd[k]=dictappend(rd[k], ar[k]) else: rd[k]=ar[k] return rd @@ -656,15 +656,15 @@ def applyrules(rules,d,var={}): ret={} if isinstance(rules, list): for r in rules: - rr=applyrules(r,d,var) - ret=dictappend(ret,rr) + rr=applyrules(r, d, var) + ret=dictappend(ret, rr) if '_break' in rr: break return ret if '_check' in rules and (not rules['_check'](var)): return ret if 'need' in rules: - res = applyrules({'needs':rules['need']},d,var) + res = applyrules({'needs':rules['need']}, d, var) if 'needs' in res: cfuncs.append_needs(res['needs']) @@ -672,11 +672,11 @@ def applyrules(rules,d,var={}): if k=='separatorsfor': ret[k]=rules[k]; continue if isinstance(rules[k], str): - ret[k]=replace(rules[k],d) + ret[k]=replace(rules[k], d) elif isinstance(rules[k], list): ret[k]=[] for i in rules[k]: - ar=applyrules({k:i},d,var) + ar=applyrules({k:i}, d, var) if k in ar: ret[k].append(ar[k]) elif k[0]=='_': @@ -688,19 +688,19 @@ def applyrules(rules,d,var={}): if isinstance(rules[k][k1], list): for i in rules[k][k1]: if isinstance(i, dict): - res=applyrules({'supertext':i},d,var) + res=applyrules({'supertext':i}, d, var) if 'supertext' in res: i=res['supertext'] else: i='' - ret[k].append(replace(i,d)) + ret[k].append(replace(i, d)) else: i=rules[k][k1] if isinstance(i, dict): - res=applyrules({'supertext':i},d) + res=applyrules({'supertext':i}, d) if 'supertext' in res: i=res['supertext'] else: i='' - ret[k].append(replace(i,d)) + ret[k].append(replace(i, d)) else: errmess('applyrules: ignoring rule %s.\n'%repr(rules[k])) if isinstance(ret[k], list): |