lundi 18 septembre 2017

'int' object is not iterable - while not loop with booleans

I have the following problem: I want to use a while not loop under a true-false condition. I define the condition and tell the loop what to do while the condition is True and False respectively. However, in the line 'converge = False, j = 1' (please see code below), I get the message 'int' object is not iterable. Can you help please? I don't know what the problem here is as I am fairly new to python.

Condition that the model run should stop at steady state (when the slope does not change anymore)

Final_pools_2 = [pools_2[-1,:]]
converge = False, j = 1
while not converge:
    parset_2[-6:] = Final_pools_2
    j = j+1
    fluxes_2,pools_2 = f2py.dalec(fluxes_2,pools_2,drivers,-10.,deltat,removal,fires,parset_2,1)
    Final_pools_2.append(pools_2[-1,:])
    test = 1-np.abs(Final_pools_2[-1]/parset_2[-6:])
    if test > 0.001:
        converge = True
Final_pools_2 = np.array(Final_pools_2)

Thanks for your help :)

Aucun commentaire:

Enregistrer un commentaire