Skip to content

Commit

Permalink
Merge pull request #56 from zengfung/dev
Browse files Browse the repository at this point in the history
Temporary fix to unit test error
  • Loading branch information
zengfung authored Jun 7, 2022
2 parents f7e113c + f8af952 commit 4f3bee0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 46 deletions.
6 changes: 2 additions & 4 deletions src/mod/Visualizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,9 @@ function wiggle!(plt::Plots.Plot,
# generate the desired plots as of O3/19/2018. Somehow, the relative value of 0,
# i.e., fillrange=0, works well, which is used temporarily.
if Orient == :down
plot!(plt, inputy, inputx, fillrange=0, fillalpha=0.75,
fillcolor=FaceColor, linecolor=EdgeColor, orientation=:v)
plot!(plt, inputy, inputx, fillrange=0, fillalpha=0.75, fillcolor=FaceColor, linecolor=EdgeColor, orientation=:v)
else
plot!(plt, inputx, inputy, fillrange=0, fillalpha=0.75,
fillcolor=FaceColor, linecolor=EdgeColor)
plot!(plt, inputx, inputy, fillrange=0, fillalpha=0.75, fillcolor=FaceColor, linecolor=EdgeColor)
end
end
return plt
Expand Down
90 changes: 48 additions & 42 deletions test/visualizations.jl
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
tree = BitVector([1,1,1])
@test Visualizations.treenodes_matrix(tree) == BitArray([1 1; 1 1])
# plot_tfbdry() test
p = plot()
@test isa(plot_tfbdry(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry(p, tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry!(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry!(p, tree), Plots.Plot{Plots.GRBackend})
@test_nowarn plot_tfbdry(tree, start=1)
@test_throws AssertionError plot_tfbdry(tree, start=2)
@test_nowarn plot_tfbdry(tree, node_color=:red, background_color=:white, line_color=:black)
# plot_tfbdry2() test
tree = maketree(4,4,2,:dwt)
p = plot()
@test isa(plot_tfbdry2(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2(p, tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2!(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2!(p, tree), Plots.Plot{Plots.GRBackend})
@test_nowarn plot_tfbdry2(tree)
@test_nowarn plot_tfbdry2(tree, 4)
@test_nowarn plot_tfbdry2(tree, 4, 8)
@test_throws AssertionError plot_tfbdry2(tree, 3, 8)
@test_throws AssertionError plot_tfbdry2(tree, 4, 3)
@test_throws AssertionError plot_tfbdry2(tree, 6, 6)
x = randn(16,5)
# wiggle() test
@test typeof(wiggle(x)) == Plots.Plot{Plots.GRBackend}
p = plot()
@test typeof(wiggle(p, x)) == Plots.Plot{Plots.GRBackend}
# wiggle!() test
@test typeof(wiggle!(x)) == Plots.Plot{Plots.GRBackend}
@test typeof(wiggle!(p, x)) == Plots.Plot{Plots.GRBackend}
@test_throws ErrorException("Inconsistent taxis dimension!") wiggle!(p, x, taxis=1:5)
@test_throws ErrorException("Inconsistent zaxis dimension!") wiggle!(p, x, zaxis=1:4)
@test_nowarn wiggle!(p, x, sc=0.3)
@test_nowarn wiggle!(p, x, EdgeColor=:red)
@test_nowarn wiggle!(p, x, FaceColor=:red)
@test_nowarn wiggle!(p, x, Overlap=false)
@test_nowarn wiggle!(p, x, Orient=:down)
@test_throws AssertionError wiggle!(p, x, Orient=:fail)
@test_nowarn wiggle!(p, x, ZDir=:reverse)
@test_throws AssertionError wiggle!(p, x, ZDir=:fail)
@testset "plot_tfbdry" begin
tree = BitVector([1,1,1])
@test Visualizations.treenodes_matrix(tree) == BitArray([1 1; 1 1])
p = plot()
@test isa(plot_tfbdry(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry(p, tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry!(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry!(p, tree), Plots.Plot{Plots.GRBackend})
@test_nowarn plot_tfbdry(tree, start=1)
@test_throws AssertionError plot_tfbdry(tree, start=2)
@test_nowarn plot_tfbdry(tree, node_color=:red, background_color=:white, line_color=:black)
end

@testset "plot_tfbdry2" begin
tree = maketree(4,4,2,:dwt)
p = plot()
@test isa(plot_tfbdry2(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2(p, tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2!(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2!(p, tree), Plots.Plot{Plots.GRBackend})
@test_nowarn plot_tfbdry2(tree)
@test_nowarn plot_tfbdry2(tree, 4)
@test_nowarn plot_tfbdry2(tree, 4, 8)
@test_throws AssertionError plot_tfbdry2(tree, 3, 8)
@test_throws AssertionError plot_tfbdry2(tree, 4, 3)
@test_throws AssertionError plot_tfbdry2(tree, 6, 6)
end

@testset "wiggle" begin
x = randn(16,5)
# wiggle() test
@test typeof(wiggle(x)) == Plots.Plot{Plots.GRBackend}
p = plot()
@test typeof(wiggle(p, x)) == Plots.Plot{Plots.GRBackend}
# wiggle!() test
@test typeof(wiggle!(x)) == Plots.Plot{Plots.GRBackend}
@test typeof(wiggle!(p, x)) == Plots.Plot{Plots.GRBackend}
@test_throws ErrorException("Inconsistent taxis dimension!") wiggle!(p, x, taxis=1:5)
@test_throws ErrorException("Inconsistent zaxis dimension!") wiggle!(p, x, zaxis=1:4)
@test_nowarn wiggle!(p, x, sc=0.3)
@test_nowarn wiggle!(p, x, EdgeColor=:red)
@test_nowarn wiggle!(p, x, FaceColor=:red)
@test_nowarn wiggle!(p, x, Overlap=false)
@test isa(wiggle!(p, x, Orient=:down), Plots.Plot{Plots.GRBackend}) # TODO: Keyword plot(orientation) deprecated. Figure out long term solution to this.
@test_throws AssertionError wiggle!(p, x, Orient=:fail)
@test_nowarn wiggle!(p, x, ZDir=:reverse)
@test_throws AssertionError wiggle!(p, x, ZDir=:fail)
end

0 comments on commit 4f3bee0

Please sign in to comment.