-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tutorial for (mostly Symbol based) interfacing with problems, integrators, and solutions #639
Conversation
This should be ready for merging, if checks pass. |
end | ||
cb = PresetTimeCallback(condition, affect!) | ||
|
||
sol = solve(deepcopy(jprob), SSAStepper(); callback=cb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sol = solve(deepcopy(jprob), SSAStepper(); callback=cb) | |
sol = solve(jprob, SSAStepper(); callback=cb) |
Why are you using deepcopy
? I wouldn't use this in a tutorial as it will just lead to confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I though deepcopy
was the way to go for complicated structures with other structures within them? Happy to be corrected though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you copying it at all though? You just defined it 11 lines above.
The only reason to deepcopy is if you are going to change something in it and want to keep the original around, but you never use it again so I'm not sure why it being mutated matters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admittedly this is the last solve
of the problem in this example, but assuming hypothetical following code this seems sensible though? Or imagine someone just rerunning that last line 2-3 times to see different solutions.
It feels like good practise to pass a copy of the problem when using mutating callbacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admittedly this is the last solve
of the problem in this example, but assuming hypothetical following code this seems sensible though? Or imagine someone just rerunning that last line 2-3 times to see different solutions.
It feels like good practise to pass a copy of the problem when using mutating callbacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better example here is to run and plot like 10 solutions. Then you would need to keep the original around as indeed I think you'd have an issue without using deep copies due to the mutation (i.e. the problem would be in an inconsistent state on the next simulation). Then you can use deepcopy
, but I'd also add an explanation then for why it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But to be honest, the better approach would be to show users how to then reset things via mutation of the original problem again to have the original values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to keep the example focused, and not make a full ensemble as that is pretty much a repeat of another tutorial. Will do some more explaining of deepcopy, and link the ensemble example where I actually show why the deepcopy
is important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But to be honest, the better approach would be to show users how to then reset things via mutation of the original problem again to have the original values.
How you mean, just reset the value after the simulation has finished?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so this example is proceeded by one where we explain, with examples, why deepcopy
is needed (line 185 to 265). I think is is well explained, but tell me if you think there should be further changes.
docs/src/catalyst_applications/simulation_structure_interfacing.md
Outdated
Show resolved
Hide resolved
docs/src/catalyst_applications/simulation_structure_interfacing.md
Outdated
Show resolved
Hide resolved
docs/src/catalyst_applications/simulation_structure_interfacing.md
Outdated
Show resolved
Hide resolved
docs/src/catalyst_applications/simulation_structure_interfacing.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
…g.md Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
…g.md Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
…g.md Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
…g.md Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
…ate_doc_interfacing
Could you fix the examples that are failing and giving errors when building the docs? After that feel free to merge -- I can't really read through till mid-next week, and I can just tweak it if I want to update anything at that time. |
Add a new tutorial on how to e.g. do
sol[:X1]
to get solution values ofX1
. Also mentioned remake and how to doand use
X1
instead of:X1
.Makes minor modifications in the callback and plotting description of the advanced simulation tutorial to use this notation.