Add Unit tests for event I/O
Description:
We need to implement unit tests for the I/O functionality related to the Event type and its associated save and load functions. These functions are responsible for serializing and deserializing event data to and from HDF5 format.
Code to be Covered
The I/O concerns the following core components:
struct Event{PSP <: AbstractPhaseSpacePoint, T <: Number}
psp::PSP
weight::T
end
function save(event_list::AbstractVector{<:Event}, path::String = "data.h5")
...
end
function load(filepath::String, proc, model, psl)
...
end
Why This Is Important
- Currently, there are no tests verifying that the saved data can be correctly read back in.
- Bugs in this code can lead to subtle and hard-to-detect inconsistencies in downstream data usage.
- The
_to_moms_tuplehelper function does non-trivial conversion and should also be validated.
What Needs to Be Tested
-
Round-trip integrity: load(save(events)) ≈ events -
Edge cases: empty event list, single event, varying momentum dimensionality -
File overwrite and default path behavior -
Type stability and structural correctness of deserialized objects -
_to_moms_tupleconversion logic
Suggested Approach
- Create synthetic
Eventobjects using mockAbstractPhaseSpacePointinstances. - Save them to a temporary file using
save. - Reload using
loadand compare field values (momenta, weights) with originals.
Edited by Uwe Hernandez Acosta