Skip to content
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

Flush callbacks and trajectory #35

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Flush callbacks and trajectory
  • Loading branch information
romainljsimon committed Feb 13, 2025
commit 17056146d168515583da9bdf7ed3d25193d60509
5 changes: 5 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
end

function StoreCallbacks(chains, path, steps; callbacks=missing)
if ismissing(callbacks)
callbacks = []

Check warning on line 89 in src/utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils.jl#L89

Added line #L89 was not covered by tests
end
return StoreCallbacks(callbacks, path)
end

Expand All @@ -98,6 +101,7 @@
function make_step!(simulation::Simulation, algorithm::StoreCallbacks)
for (callback, file) in zip(algorithm.callbacks, algorithm.files)
println(file, "$(simulation.t) $(callback(simulation))")
flush(file)
end
end

Expand Down Expand Up @@ -145,6 +149,7 @@
function make_step!(simulation::Simulation, algorithm::StoreTrajectories)
for c in eachindex(simulation.chains)
store_trajectory(algorithm.files[c], simulation.chains[c], simulation.t)
flush(algorithm.files[c])
end
end

Expand Down