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 committed Nov 20, 2024
1 parent c020691 commit 34d3401
Showing 1 changed file with 16 additions and 1 deletion.
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 34d3401

Please sign in to comment.