On Aug 12, 2009, at 11:08 AM, Daniel Wheeler wrote:
On Wed, Aug 12, 2009 at 9:13 AM, Etienne
Rivard<[email protected]> wrote:
Then, at each time step, I would append the value of the variable
to the
list:
d['T'].append(T.getValue())
The problem is that each entry of the list is evaluated (lazy
evaluation)
when it's called and a the end, I get a list with a series of
identical
entries.
I'm really confused that this doesn't work. getValue should guarantee
an evaluation. I'll look into it. In the meantime use numerix.array(T)
to guarantee an evaluation where you ask for it. getValue should
probably be made to do the same as array_wray or whatever
numerix.array uses, but I need to look into it before saying more.
I think the issue is that T is a solution variable, not the result of
an operation, so there's no evaluation to do. T.getValue() just
returns T.value, which is a reference to an array. When the value of T
changes (e.g. via T.setValue()), the contents of T.value are changed,
but the reference remains the same (it's the same array object).
d['T'] ends up holding a list of identical references to T.value, and
so they all see the most recent value stored.
I'm now considering
d['T'].append(copy(T.getValue()))
Would that be a good solution or is there something better?
I think this may be your best option.