[Python-talk] Can I do this?
bruce.labitt at autoliv.com
bruce.labitt at autoliv.com
Wed Feb 3 17:07:59 EST 2010
I seem to recall a gotcha on this... Can anyone help me sort through
this?
Can't seem to remember if this sort of construct will do what I want...
# start program snippet...
dt = 1e-6
t = arange(100)*dt # make array of 100 elements
idx = 0
omega, rho = 3.*pi/4., 1.
funcs = [f0, f1, f2, f3, f4] # fn are functions that are previously
defined
args1 = [ (args for f0), (args for f1), (args for f2), (args for f3),
(args for f4)]
"""args1 contains the arguments for funcs"""
p = getRank(M) # only thing that is important about p is that it
is calculated
# p is bounds checked
WW = zeros((p, t.size), dtype='complex128') # declare a px100 complex
array
funclist = funcs[:p] # just select the first p functions of func
arglist = args1[:p] # likewise the first p args to feed to the
corresponding function
for bb, func, argn in zip( range(p), funclist, arglist):
idx = bb
WW[bb,:] = func( *argn )
Inside of args1[i] are tuples of parameters.
For example:
args1[0] = ( idx, t, snr )
args1[3] = ( idx, t, snr, omega, rho )
Do I need to update arglist for every iteration of the loop? Then I
should remove arglist from the zip, right?
More like
for bb, func in zip( range(p), funclist ):
args1 = [( bb, t, snr), ..., (bb, t, snr, omega, rho), ... ]
WW[bb,:] = func( *args1[bb] )
??? Seems kind of silly just to update only the index... An easier way
possible?
I'm leaning a lot closer to the second "for loop" than the first... Right
decision?
Bruce
Bruce Labitt
Autoliv Electronics
1011B Pawtucket Blvd, PO Box 1858
Lowell, MA 01853
Email: bruce.labitt at autoliv.com.
Tel: (978) 674-6526
Fax: (978) 674-6581
******************************
Neither the footer nor anything else in this E-mail is intended to or constitutes an <br>electronic signature and/or legally binding agreement in the absence of an <br>express statement or Autoliv policy and/or procedure to the contrary.<br>This E-mail and any attachments hereto are Autoliv property and may contain legally <br>privileged, confidential and/or proprietary information.<br>The recipient of this E-mail is prohibited from distributing, copying, forwarding or in any way <br>disseminating any material contained within this E-mail without prior written <br>permission from the author. If you receive this E-mail in error, please <br>immediately notify the author and delete this E-mail. Autoliv disclaims all <br>responsibility and liability for the consequences of any person who fails to <br>abide by the terms herein. <br>
******************************
More information about the Python-talk
mailing list