You’re getting the error message
ValueError: setting an array element with a sequence.
because you’re trying to set an array element with a sequence. I’m not trying to be cute, there — the error message is trying to tell you exactly what the problem is. Don’t think of it as a cryptic error, it’s simply a phrase. What line is giving the problem?
This line tries to set the
ith element of
kOUT to whatever
func(TempLAke[i], Z) returns. Looking at the
In : kOUT Out: 0.0 In : func(TempLake, Z) Out: array([ 0., 0., 0., 0.])
You’re trying to load a 4-element array into
kOUT which only has a float. Hence, you’re trying to set an array element (the left hand side,
kOUT[i]) with a sequence (the right hand side,
func isn’t doing what you want, but I’m not sure what you really wanted it to do (and don’t forget you can usually use vectorized operations like A*B rather than looping in numpy.) That should explain the problem, anyway.