Hi Etienne, Answers below. On Wed, Aug 12, 2009 at 9:13 AM, Etienne Rivard<[email protected]> wrote: > > Hello Everyone, > > > I have a problem related to saving the results I get with fipy. It's in some > way related to my previous post entitled "Using functions from the math or > numpy modules". > > I'm working on a transient problem and I need to store the values of my > variables at each time step. I decided to use a dictionary for that purpose > because it's easy to pickle for latter use. For example, if I had a variable > "T": > > d = {'T': []} > > 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. > So, my question is: What would be the best way of bypassing the lazy > evaluation and just save the numerical values? I tried > > T.getNumericalValue() I think this is just the same as getValue. > but that didn't work. > > I'm now considering > > d['T'].append(copy(T.getValue())) > > Would that be a good solution or is there something better? numerix.array() or [:] is the most canonical, numerix.array will work for all types though, [:] will break for stuff without length. Thanks for pointing out this weird behavior of Variable's. -- Daniel Wheeler
