|
1 | | -using Test, LinearAlgebra, Statistics |
2 | | -using StableRNGs |
3 | | -using Lighthouse |
4 | | -using Lighthouse: plot_reliability_calibration_curves, plot_pr_curves, |
5 | | - plot_roc_curves, plot_kappas, plot_confusion_matrix, |
6 | | - evaluation_metrics_plot, evaluation_metrics, binarize_by_threshold |
7 | | -using Base.Threads |
8 | | -using CairoMakie |
9 | | -using Legolas, Tables |
10 | | -using DataFrames |
11 | | -using Arrow |
| 1 | +include("set_up_tests.jl") |
12 | 2 |
|
13 | | -# Needs to be set for figures |
14 | | -# returning true for showable("image/png", obj) |
15 | | -# which TensorBoardLogger.jl uses to determine output |
16 | | -CairoMakie.activate!(; type="png") |
17 | | -plot_results = joinpath(@__DIR__, "plot_results") |
18 | | -# Remove any old plots |
19 | | -isdir(plot_results) && rm(plot_results; force=true, recursive=true) |
20 | | -mkdir(plot_results) |
21 | | - |
22 | | -macro testplot(fig_name) |
23 | | - path = joinpath(plot_results, string(fig_name, ".png")) |
24 | | - return quote |
25 | | - fig = $(esc(fig_name)) |
26 | | - @test fig isa Makie.FigureLike |
27 | | - save($(path), fig) |
28 | | - end |
29 | | -end |
30 | | - |
31 | | -const EVALUATION_V1_KEYS = string.(fieldnames(EvaluationV1)) |
32 | | - |
33 | | -function test_evaluation_metrics_roundtrip(row_dict::Dict{String,S}) where {S} |
34 | | - # Make sure all metrics keys are captured in our schema and are not thrown away |
35 | | - keys_not_in_schema = setdiff(keys(row_dict), EVALUATION_V1_KEYS) |
36 | | - @test isempty(keys_not_in_schema) |
37 | | - |
38 | | - # Do the roundtripping (will fail if schema types do not validate after roundtrip) |
39 | | - record = EvaluationV1(row_dict) |
40 | | - rt_row = roundtrip_row(record) |
41 | | - |
42 | | - # Make sure full row roundtrips correctly |
43 | | - @test issetequal(keys(record), keys(rt_row)) |
44 | | - for (k, v) in pairs(record) |
45 | | - if ismissing(v) |
46 | | - @test ismissing(rt_row[k]) |
47 | | - else |
48 | | - @test issetequal(v, rt_row[k]) |
49 | | - end |
50 | | - end |
51 | | - |
52 | | - # Make sure originating metrics dictionary roundtrips correctly |
53 | | - rt_dict = Lighthouse._evaluation_dict(rt_row) |
54 | | - for (k, v) in pairs(row_dict) |
55 | | - if ismissing(v) |
56 | | - @test ismissing(rt_dict[k]) |
57 | | - else |
58 | | - @test issetequal(v, rt_dict[k]) |
59 | | - end |
60 | | - end |
61 | | - return nothing |
62 | | -end |
63 | | - |
64 | | -function roundtrip_row(row::EvaluationV1) |
65 | | - io = IOBuffer() |
66 | | - tbl = [row] |
67 | | - Legolas.write(io, tbl, Lighthouse.EvaluationV1SchemaVersion()) |
68 | | - return EvaluationV1(only(Tables.rows(Legolas.read(seekstart(io))))) |
| 3 | +@testset "Aqua" begin |
| 4 | + # we ignore Makie because we do a manual install of a specific |
| 5 | + # version to test specific versions |
| 6 | + Aqua.test_all(Lighthouse; |
| 7 | + ambiguities=false, stale_deps=(; ignore=[:Makie])) |
69 | 8 | end |
70 | 9 |
|
71 | 10 | include("plotting.jl") |
|
0 commit comments