Skip to content

Commit

Permalink
Add tests for reading legend-testdata histograms
Browse files Browse the repository at this point in the history
  • Loading branch information
apmypb authored and oschulz committed Nov 21, 2024
1 parent c020691 commit 893b64f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
EncodedArrays = "97725368-735e-11e9-0dd7-6bf34c3b13a8"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
LegendDataManagement = "9feedd95-f0e0-423f-a8dc-de0970eae6b3"
LegendTestData = "33d6da08-6349-5f7c-b5a4-6ff4d8795aaf"
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
RadiationDetectorSignals = "bf2c0563-65cf-5db2-a620-ceb7de82658c"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Expand Down
17 changes: 16 additions & 1 deletion test/histograms/histogram_io.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using StatsBase

using LegendHDF5IO
using LegendTestData
using Test
using LegendHDF5IO: _nt_to_histogram, _histogram_to_nt

@testset "Histogram <-> NamedTuple" begin
Expand All @@ -9,4 +11,17 @@ using LegendHDF5IO: _nt_to_histogram, _histogram_to_nt
@test _nt_to_histogram(_histogram_to_nt(h)) == h
h = fit(Histogram, (rand(10), rand(10)), (0:0.2:1, Float64[0, 0.5, 1]))
@test _nt_to_histogram(_histogram_to_nt(h)) == h
end

@testset "Histogram IO" begin
fn = joinpath(legend_test_data_path(), "data", "lh5", "lgdo-histograms.lh5")
lh5open(fn) do h5
names = keys(h5)
for name in names
@testset "$name" begin
h = @test_nowarn h5[name]
@test h isa Histogram
end
end
end
end

0 comments on commit 893b64f

Please sign in to comment.