Skip to content

Commit

Permalink
Add tests for plots
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromxavier committed Jan 6, 2023
1 parent 7d5de22 commit b91af05
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Test
using Printf
using SparseArrays
using RecipesBase
using QUBOTools

import QUBOTools: , , 𝔹, 𝕊
import QUBOTools: Sample, SampleSet
import QUBOTools: CodecError, codec_error
Expand Down
2 changes: 2 additions & 0 deletions test/unit/analysis/analysis.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include("metrics.jl")
include("plots.jl")

function test_analysis()
test_metrics()
test_plots()
end
30 changes: 30 additions & 0 deletions test/unit/analysis/plots.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function test_plots()
@testset "■ Plots ■" verbose = true begin
test_sampleset_plot()
end
end

function test_sampleset_plot()
@testset "SampleSet" begin
ω = SampleSet([
Sample([0, 0], 1.0, 1),
Sample([0, 1], 2.0, 2),
Sample([1, 0], 3.0, 3),
Sample([1, 1], 4.0, 4),
])

let r = RecipesBase.apply_recipe(Dict{Symbol,Any}(), ω)
@test length(r) == 1
@test length(r[].args) == 2

x, y = r[].args
attr = r[].plotattributes

@test x == [1.0, 2.0, 3.0, 4.0]
@test y == [1, 2, 3, 4]

@test attr[:ylabel] == "Frequency"
@test attr[:xlabel] == "Energy"
end
end
end

0 comments on commit b91af05

Please sign in to comment.