[portland] Need Help With a For Loop

Rich Shepard rshepard at appl-ecosys.com
Thu Mar 20 18:32:56 CET 2008


   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.

   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?

   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

-- 
Richard B. Shepard, Ph.D.               |  Integrity            Credibility
Applied Ecosystem Services, Inc.        |            Innovation
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863


More information about the Portland mailing list