Skip to content

Commit

Permalink
Merge pull request #18 from legend-exp/codecov
Browse files Browse the repository at this point in the history
Increase code coverage to 100%
  • Loading branch information
fhagemann authored Mar 2, 2025
2 parents 018c116 + 6dc4294 commit 39543a3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/LegendMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ module LegendMakie
include("register_extdeps.jl")

function __init__()
# _register_extension_deps(
# some_custom_waveform_plot => :RadiationDetectorSignals,
# )
_register_extension_deps(
lplot => :Makie,
lplot! => :Makie,
lhist => :Makie,
lhist! => :Makie,
lsavefig => :Makie
)
end

end # module
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LegendDataManagement = "9feedd95-f0e0-423f-a8dc-de0970eae6b3"
Expand Down
21 changes: 19 additions & 2 deletions test/test_lplot.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is a part of LegendMakie.jl, licensed under the MIT License (MIT).

using LegendMakie
using Makie
using Makie, CairoMakie

import LegendSpecFits
import LegendDataManagement
Expand All @@ -17,6 +17,22 @@ import Unitful: @u_str

using Test

@testset "lsavefig" begin
# Empty figures cannot be plotted
@test_throws ArgumentError lsavefig("empty.pdf")
@test !isfile("empty.pdf")
for fileformat in ("pdf", "png", "svg")
@testset "Fileformat: $(fileformat)" begin
fn = "test.$(fileformat)"
isfile(fn) && rm(file)
Makie.scatter(rand(10), rand(10))
@test_nowarn lsavefig(fn)
@test isfile(fn)
rm(fn)
end
end
end

@testset "lplot" begin
@testset "Test watermarks" begin

Expand All @@ -31,6 +47,7 @@ using Test
ax2 = Axis(fig[1,2])
@test_nowarn LegendMakie.residualplot!(ax2, (x = 1:10, residuals_norm = randn(10)))
@test_nowarn LegendMakie.add_watermarks!(legend_logo = true, position = "outer top", preliminary = false)
@test_throws ArgumentError LegendMakie.add_watermarks!(position = "Test")
end

@testset "Test LegendSpecFits reports" begin
Expand Down Expand Up @@ -78,7 +95,7 @@ using Test
end
result_fit, report_fit = LegendSpecFits.fit_peaks(result_simple.peakhists, result_simple.peakstats, lines; e_unit=result_simple.unit, calib_type=:th228, m_cal_simple=m_cal_simple)
@testset "Fit peaks for energy calibration" begin
@test_nowarn lplot(report_fit, figsize = (600, 400*length(report_fit)), watermark = false)
@test_nowarn lplot(report_fit, figsize = (600, 400*length(report_fit)), watermark = false, title = "Test")
end
μ_fit = getfield.(getindex.(Ref(result_fit), lines), :centroid)
result_calib, report_calib = LegendSpecFits.fit_calibration(1, μ_fit, energies)
Expand Down

0 comments on commit 39543a3

Please sign in to comment.