Hello everyone,
I just stumbled upon something else that is confusing to me, but it might be somewhat related, so I will post it here as well.
I wrote a test equation to illustrate this second issue:
class Test(Equation):
def __init__(self, dest, sources):
self.test = 1.0
super(Test, self).__init__(dest, sources)
def py_initialize(self, dst, t, dt):
self.test = 2.0
print('py_initialize: '+str(self.test))
def loop(self):
print('loop: '+str(self.test))
def reduce(self, dst, t, dt):
print('reduce: '+str(self.test))
Ignoring the first iteration, I expected this to output '2.0' for all three functions. Instead, it outputs this:
py_initialize: 2.0
loop: 1.0
(...)
loop: 1.0
reduce: 1.0
So I thought, 'self.test' could only be changed within each function. But when I change the parameter in 'reduce' instead, like so:
class Test(Equation):
def __init__(self, dest, sources):
self.test = 1.0
super(Test, self).__init__(dest, sources)
def py_initialize(self, dst, t, dt):
print('py_initialize: '+str(self.test))
def loop(self):
print('loop: '+str(self.test))
def reduce(self, dst, t, dt):
self.test = 2.0
print('reduce: '+str(self.test))
The output from the second iteration onwards will be:
py_initialize: 1.0
loop: 2.0
(...)
loop: 2.0
reduce: 2.0
So 'self.test' will stay the same for 'py_initialize', but not for the other two functions. I am a bit confused, is this the expected behavior?
Regards,
Lukas