Closed lindnemi closed 4 years ago
I think this is working as expected.
If you mutate variables that are defined outside of your scope, then that's going to cause issues if other things are also using those variables, both in Interact and otherwise.
I don't think there's a good way to circumvent this or warn about this because the @manipulate
macro doesn't know what is going to be mutated outside of the macro (or even that, for example, g!
will mutate the variable).
I'm going to close this since it's working as expected. Feel free to continue the discussion if you have more you'd like to say.
In a jupyter notebook I am defining several ODEProblems and use Interact @manipulate to inspect the solutions. I use the variable
x0
for the initial conditions. For the second problem i am reusing the variablex0
and assign different values to it. However this affects the first widget, changing the plots it displays and sometimes causing it to break with an error message.This behaviour is very counter-intuitive since it allows to change previous outputs!
Minimal working example:
Pulling the definition of x0 into the for-loop solves the issue. I was surprised that something like this can happen since i naively assumed that Interact caches the different plots.
Would it possible to avoid this behaviour or at least to display a warning, that the internal variables of the widget have been changed?