[portland] Need Help With a For Loop

mark gross markgross at thegnar.org
Fri Mar 21 03:38:02 CET 2008


On Thu, Mar 20, 2008 at 10:32:56AM -0700, Rich Shepard wrote:
>    I cannot see what's causing the error I see, but it must be something
> simple that I've overlooked. Your more experienced eyes will probably see
> it.
> 
>    Here's the for loop:
> 
>  	for i in range(1, compList[0][16]):
>            pylab.hold(True)
>            if compList[0][4] == 'Decay S-Curve':
>              testFunctions.zCurve(compList[0][10],compList[0][9])
>            elif compList[0][4] == 'Bell Curve':
>              testFunctions.gaussCurve(compList[0][14],compList[0][14])
>            elif compList[0][4] == 'Growth S-Curve':
>              testFunctions.sCurve(compList[0][8],compList[0][11])
>            elif compList[0][4] == 'Beta':
>  	    testFunctions.betaCurve(compList[0][13],compList[0][12],compList[0][14])
>            elif compList[0][4] == 'Data':
>              continue
>            elif compList[0][4] == 'Linear Increasing':
>              testFunctions.linearIncrCurve(compList[0][8],compList[0][11])
>            elif compList[0][4] == 'Linear Decreasing':
>              testFunctions.linearDecrCurve(compList[0][10],compList[0][9])
>            elif compList[0][4] == 'Left Shoulder':
>  	    testFunctions.leftShoulderCurve(compList[0][10],compList[0][11],compList[0][9])
>              continue
>            elif compList[0][4] == 'Trapezoid':
>  	    testFunctions.trapezoidCurve(compList[0][8],compList[0][10],compList[0][11],compList[0][9])
>              continue
>            elif compList[0][4] == 'Right Shoulder':
>  	    testFunctions.rightShoulderCurve(compList[0][8],compList[0][10],compList[0][11])
>              continue
>            elif compList[0][4] == 'Triangle':
>  	    testFunctions.triangleCurve(compList[0][8],compList[0][13],compList[0][9])
>            elif compList[0][4] == 'Singleton':
>              testFunctions.singletonCurve(compList[0][13],compList[0][14])
>            elif compList[0][4] == 'Rectangle':
>  	    testFunctions.rectangleCurve(compList[0][8],compList[0][10],compList[0][11],compList[0][9])
>            elif compList[0][4] == 'Outcome':
>              testFunctions.outcomeCurve()
>          pylab.savefig(curVar+'.png')
> 
>    The first 'i' passes the first 'if' test and control passes to
> testFunctions.zCurve(). When that function returns, the program is NOT at the
> 'for' statement again, but at one earlier in the code.

perhaps I'm missing something but I'm not seeing where the i variable
is used in the loop block.

> 
>    So, instead of incrementing i and running through the if tests (which
> should take it to the one for 'Growth S-Curve', it repeats the same plotting
> function call then immediately jumps to pylab.savefig().
> 
>    Why?

not referencing i anywhere ?


--mgross

> 
>    I can provide the test code with data and the ancillary module with the
> plotting functions, but you'd need NumPy and Matplotlib installed to run it.
> 
> TIA,
> 
> Rich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/portland/attachments/20080320/cfad6b28/attachment.pgp 


More information about the Portland mailing list