From 10628db92b4f9bb4c11d76580280ead6ed15e43c Mon Sep 17 00:00:00 2001
From: Lukas Hupe <lukas.hupe@ds.mpg.de>
Date: Fri, 17 Feb 2023 12:44:50 +0100
Subject: [PATCH 01/11] bump version to 0.3.12-dev

---
 CHANGELOG.md | 2 ++
 Project.toml | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 509ad8a..60804af 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
 # Changelog
 
+## v0.3.12
+
 ## v0.3.11
  - bugfix: boxing for 3D inverted DiskObstacles has been fixed
  - fallback constructors for obstacles with `inverted` field now work without having to specify type parameters
diff --git a/Project.toml b/Project.toml
index b3b97c0..edc5522 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
 name = "InPartS"
 uuid = "f768f48f-0d8a-415b-80aa-7de5ff9b8474"
 authors = ["Lukas Hupe <lukas.hupe@ds.mpg.de>", "Jonas Isensee <jonas.isensee@ds.mpg.de>", "Philip Bittihn <philip.bittihn@ds.mpg.de>"]
-version = "0.3.11"
+version = "0.3.12-dev"
 
 [deps]
 FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
-- 
GitLab


From 30d7e04ba5d5fde4e5f7390074c847487b8358cc Mon Sep 17 00:00:00 2001
From: jisense <jonas.isensee@ds.mpg.de>
Date: Wed, 15 Mar 2023 10:29:02 +0000
Subject: [PATCH 02/11] Update src/export/generic.jl

---
 src/export/generic.jl | 47 +++++++++++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/src/export/generic.jl b/src/export/generic.jl
index 176cb88..2ecf334 100644
--- a/src/export/generic.jl
+++ b/src/export/generic.jl
@@ -1,31 +1,37 @@
 export SaveCallback, BackupCallback, readsim
 
 ## Datafile interface definitions
-"""
-    dfopen(backend, filename; kwargs...)
-    dfopen(backend, filename, mode::String)
-Open the data file at `filename`.
 
-Mode specifications follow [`Base.open`](@ref).
 """
-dfopen(type::Type, filename::String, mode::String) = dfopen(type, filename; modetoflags(mode)...)
-dfopen(@nospecialize(type::Type), filename::String; kwargs...) = error("Unknown export backend: $type")
-
-function dfopen(filename::String, mode::String="r")
+    exportbackend(filename)
+A bit of sugar around `FileIO.query`.
+"""
+function backend(filename::String)
     s = FileIO.query(filename)
     modulename = typeof(s).parameters[1].parameters[1]
     if !isdefined(Main, modulename)
         error("File appears to be a $modulename file but library is not loaded.")
     end
     if modulename == :JLD2
-        return dfopen(JLD2.JLDFile, filename, mode)
+        return JLD2.JLDFile
     elseif modulename == :HDF5
-        return dfopen(H5Wrapper, filename, mode)
+        return H5Wrapper
     else
         error("This backend is not implemented")
     end
 end
 
+"""
+    dfopen(backend, filename; kwargs...)
+    dfopen(backend, filename, mode::String)
+Open the data file at `filename`.
+
+Mode specifications follow [`Base.open`](@ref).
+"""
+dfopen(type::Type, filename::String, mode::String) = dfopen(type, filename; modetoflags(mode)...)
+dfopen(@nospecialize(type::Type), filename::String; kwargs...) = error("Unknown export backend: $type")
+dfopen(filename::String, mode::String="r") = dfopen(backend(filename), filename, mode)
+
 function dfopen(f::Function, args...; kwargs...)
     file = dfopen(args...; kwargs...)
     try
@@ -88,7 +94,7 @@ mutable struct SaveCallback{FT, CB<:AbstractCallback, FN<:Function} <: AbstractC
 end
 
 """
-    SaveCallback(backend, filename; [interval = 1.0], [offset = 0.0], [dumprng = (s, sim) -> (s.nextsnap % 10 == 0)], [warn = true])
+    SaveCallback([backend], filename; [interval = 1.0], [offset = 0.0], [dumprng = (s, sim) -> (s.nextsnap % 10 == 0)], [warn = true])
 Create a [`SaveCallback`](@ref) that periodically saves simulation snapshots to `filename`.
 
 Uses a [`PeriodicCallback`](@ref) with the given `interval` and `offset`.
@@ -96,6 +102,7 @@ Uses a [`PeriodicCallback`](@ref) with the given `interval` and `offset`.
 SaveCallback(backend, filename; interval = 1.0, offset = 0.0,  dumprng = (s, sim) -> _defaultdumprng(sim.rng, s), warn = true) =
     SaveCallback{backend}(PeriodicCallback(sim -> true, interval; offset = offset), filename, dumprng, warn)
 
+SaveCallback(filename::String; kwargs...) = SaveCallback(backend(filename), filename; kwargs...)
 
 function (s::SaveCallback)(sim::Simulation)
     if !s.initialized
@@ -182,6 +189,8 @@ Uses a [`RealTimeCallback`](@ref) with the given `interval` and `offset`.
 """
 BackupCallback(backend, filename; interval = 300.0, offset = 0.0, warn = true) =
     BackupCallback{backend}(RealTimeCallback(interval, sim -> true; offset = offset), filename, warn)
+BackupCallback(filename::String; kwargs...) =
+    BackupCallback(backend(filename), filename; kwargs...)
 
 
 function(cb::BackupCallback{FT})(sim::Simulation) where FT
@@ -403,7 +412,7 @@ end
 ## Convenience function for reading things
 
 """
-    readsim(backend, filename; snap, [warn = true], [kwargs...])
+    readsim(filename; snap, [warn = true], [kwargs...])
     readsim(f; snap, [warn = true], [kwargs...])
 Read a simulation from file and load the specified snapshot.
 
@@ -420,8 +429,8 @@ function readsim(f; snap, warn = true, kwargs...)
     return sim
 end
 
-function readsim(backend, filename; kwargs...)
-    f = dfopen(backend, filename, "r")
+function readsim(filename; kwargs...)
+    f = dfopen(filename, "r")
     sim = missing
     try
         sim = readsim(f; kwargs...)
@@ -649,6 +658,12 @@ function readsnap!(sim::Simulation, snapgroup; warn::Bool = true)
     return sim
 end
 
+function readsnap!(sim::Simulation, filename::String, snap; kwargs...)
+    dfopen(filename) do f
+        readsnap!(sim, f, snap; kwargs...)
+    end
+end
+
 function readsnap!(sim::Simulation, f, snap; warn::Bool=true)
     if length(keys(f)) == 1
         legacy_readsnap!(sim, f, snap; warn=warn)
@@ -665,6 +680,7 @@ function numsnaps(f)
         length(keys(f[SNAPGROUPNAME]))
     end
 end
+numsnaps(filename::String) = dfopen(numsnaps, filename)
 
 ## Stuff
 
@@ -685,6 +701,7 @@ function latest_full_snap(f)
     end
     return -1
 end
+latest_full_snap(filename::String) = dfopen(latest_full_snap, filename)
 
 ## RNG stuff
 
-- 
GitLab


From bc3274d4660ffe43bc1fa73e9f2cfe6db79e20b4 Mon Sep 17 00:00:00 2001
From: Jonas Isensee <jonas.isensee@ds.mpg.de>
Date: Thu, 13 Apr 2023 15:13:38 +0000
Subject: [PATCH 03/11] access wrong iterator

---
 src/evolve.jl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/evolve.jl b/src/evolve.jl
index 3b6c385..69090c5 100644
--- a/src/evolve.jl
+++ b/src/evolve.jl
@@ -113,13 +113,13 @@ function propagate!(sim::Simulation, dt)
     iter2 = alldynamicobjects(sim)
     if isthreaded(sim)
         Threads.@threads for n in eachindex(iter2)
-            particle = iter[n]
+            particle = iter2[n]
             fold_back!(particle, sim.domain)
             reset!(particle, sim)
         end
     else
         for n in eachindex(iter2)
-            particle = iter[n]
+            particle = iter2[n]
             fold_back!(particle, sim.domain)
             reset!(particle, sim)
         end
-- 
GitLab


From 5b496be64cdb0935652094e5555d42cca5fd676c Mon Sep 17 00:00:00 2001
From: Lukas Hupe <lukas.hupe@ds.mpg.de>
Date: Fri, 14 Apr 2023 15:39:49 +0000
Subject: [PATCH 04/11] Add _defaultdumprng for _GLOBAL_RNG

---
 src/export/generic.jl | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/export/generic.jl b/src/export/generic.jl
index 176cb88..64c9bfa 100644
--- a/src/export/generic.jl
+++ b/src/export/generic.jl
@@ -111,6 +111,8 @@ function (s::SaveCallback)(sim::Simulation)
 end
 
 # Xoshiros are small and can be dumped every snapshot, MersenneTwisters are huge and shouldn't be written as often
+# the GLOBAL_RNG can't be properly serialized anyway so we just give up
+_defaultdumprng(::Random._GLOBAL_RNG) = false 
 _defaultdumprng(::Random.Xoshiro, _) = true
 _defaultdumprng(::Random.MersenneTwister, s) = (s.nextsnap % 10 == 0)
 
-- 
GitLab


From 277315c398e32c8ac3a2533edd9d22014177cdc0 Mon Sep 17 00:00:00 2001
From: Lukas Hupe <lukas.hupe@ds.mpg.de>
Date: Fri, 14 Apr 2023 15:51:07 +0000
Subject: [PATCH 05/11] Update CHANGELOG.md

---
 CHANGELOG.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 60804af..10f589c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
 # Changelog
 
 ## v0.3.12
+ - bugfix: ParticleContainers can now safely return distinct objects on succesive calls of alldynamicobjects (as originally intended)
+ - bugfix: a default full serialization condition interval for the global RNG has been added (the condition is `false`)
 
 ## v0.3.11
  - bugfix: boxing for 3D inverted DiskObstacles has been fixed
-- 
GitLab


From 710a823a799741d59e3f70235768179e2da3a422 Mon Sep 17 00:00:00 2001
From: Jonas Isensee <jonas.isensee@ds.mpg.de>
Date: Mon, 17 Apr 2023 10:01:30 +0200
Subject: [PATCH 06/11] bring polo up to speed

---
 src/particlecontainers/polocontainer.jl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/particlecontainers/polocontainer.jl b/src/particlecontainers/polocontainer.jl
index a91d840..44202a2 100644
--- a/src/particlecontainers/polocontainer.jl
+++ b/src/particlecontainers/polocontainer.jl
@@ -50,7 +50,7 @@ Base.append!(pc::POLOContainer, xs) = append!(pc.pv, xs)
 
 particles(sim::Simulation{<:POLOContainer}) = sim.particles.pv
 particles(pc::POLOContainer) = pc.pv
-particletype(::POLOContainer{PT}) where PT = PT
+particletype(::POLOContainer{<:Any, PT}) where PT = PT
 flushadditions!(pc::POLOContainer, ab::Vector) = flushadditions!(pc.pv, ab)
 flushdeletions!(pc::POLOContainer, db) = flushdeletions!(pc.pv, db)
 findbyid(pc::POLOContainer, id) = findbyid(pc.pv, id)
-- 
GitLab


From 6f2be41ba6565233cd74fe1af0a5c28f8c7d1acc Mon Sep 17 00:00:00 2001
From: Lukas Hupe <lukas.hupe@ds.mpg.de>
Date: Mon, 17 Apr 2023 08:03:23 +0000
Subject: [PATCH 07/11] stricter typing

---
 src/export/generic.jl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/export/generic.jl b/src/export/generic.jl
index 2ecf334..7f755a5 100644
--- a/src/export/generic.jl
+++ b/src/export/generic.jl
@@ -429,7 +429,7 @@ function readsim(f; snap, warn = true, kwargs...)
     return sim
 end
 
-function readsim(filename; kwargs...)
+function readsim(filename::AbstractString; kwargs...)
     f = dfopen(filename, "r")
     sim = missing
     try
-- 
GitLab


From ee30c0d1c464a0b59d49df63b7088090f4d41e52 Mon Sep 17 00:00:00 2001
From: Jonas Isensee <jonas.isensee@ds.mpg.de>
Date: Mon, 17 Apr 2023 12:17:37 +0200
Subject: [PATCH 08/11] rename and deprecate latest_full_snap

---
 src/export/generic.jl | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/export/generic.jl b/src/export/generic.jl
index 7f755a5..241cc17 100644
--- a/src/export/generic.jl
+++ b/src/export/generic.jl
@@ -692,8 +692,11 @@ function nextsnapname(g)
     return snaps[end] + 1
 end
 
-
-function latest_full_snap(f)
+"""
+    lastfullsnap(f)
+Returns the index of the last full snapshot (including RNG) in the file `f`.
+"""
+function lastfullsnap(f)
     for n = (numsnaps(f)-1):-1:0
         if haskey(f[SNAPGROUPNAME][string(n)], "rng")
             return n
@@ -701,7 +704,13 @@ function latest_full_snap(f)
     end
     return -1
 end
-latest_full_snap(filename::String) = dfopen(latest_full_snap, filename)
+lastfullsnap(filename::String) = dfopen(lastfullsnap, filename)
+
+function latest_full_snap(f)
+    Base.depwarn("`$(@__MODULE__).latest_full_snap` is deprecated. \
+    Use `$(@__MODULE__).lastfullsnap` instead", :latest_full_snap)
+    return lastfullsnap(f)
+end
 
 ## RNG stuff
 
-- 
GitLab


From ebc3a44bc4c8372541c68b92c8a2847fcf96bb84 Mon Sep 17 00:00:00 2001
From: Lukas Hupe <lukas.hupe@ds.mpg.de>
Date: Mon, 17 Apr 2023 10:21:23 +0000
Subject: [PATCH 09/11] Update CHANGELOG.md

---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 10f589c..d746575 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
 ## v0.3.12
  - bugfix: ParticleContainers can now safely return distinct objects on succesive calls of alldynamicobjects (as originally intended)
  - bugfix: a default full serialization condition interval for the global RNG has been added (the condition is `false`)
+ - added convenience functions for data file handling
 
 ## v0.3.11
  - bugfix: boxing for 3D inverted DiskObstacles has been fixed
-- 
GitLab


From 5afa588ea597e9fdfd74e66f23c47da610c65854 Mon Sep 17 00:00:00 2001
From: Lukas Hupe <lukas.hupe@ds.mpg.de>
Date: Wed, 19 Apr 2023 12:39:40 +0000
Subject: [PATCH 10/11] Update CHANGELOG.md

---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d746575..7866172 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
 # Changelog
 
 ## v0.3.12
+ - bugfix: particletype for POLOContainers fixed
  - bugfix: ParticleContainers can now safely return distinct objects on succesive calls of alldynamicobjects (as originally intended)
  - bugfix: a default full serialization condition interval for the global RNG has been added (the condition is `false`)
  - added convenience functions for data file handling
-- 
GitLab


From 62a18a0fcb1a606982e579716beb8d2144ec4ffe Mon Sep 17 00:00:00 2001
From: Lukas Hupe <lukas.hupe@ds.mpg.de>
Date: Thu, 20 Apr 2023 11:25:30 +0000
Subject: [PATCH 11/11] bump version

---
 Project.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Project.toml b/Project.toml
index edc5522..507e18a 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
 name = "InPartS"
 uuid = "f768f48f-0d8a-415b-80aa-7de5ff9b8474"
 authors = ["Lukas Hupe <lukas.hupe@ds.mpg.de>", "Jonas Isensee <jonas.isensee@ds.mpg.de>", "Philip Bittihn <philip.bittihn@ds.mpg.de>"]
-version = "0.3.12-dev"
+version = "0.3.12"
 
 [deps]
 FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
-- 
GitLab