Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize layer assignment problem #16

Merged
merged 19 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Generalize tests for options
  • Loading branch information
davide-f committed Feb 7, 2022
commit 4ae4cf1e72f9726678a6713562a88dc4da592dff
2 changes: 1 addition & 1 deletion src/zarate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ end
```
"""
function solve_positions(layout::Zarate, original_graph;
force_layer::Vector{Pair{Int, Int}} = Vector{Pair{Int, Int}}())
force_layer = Vector{Pair{Int, Int}}())
graph = copy(original_graph)

# 1. Layer Assigment
Expand Down
37 changes: 21 additions & 16 deletions test/demos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ function quick_plot(graph, xs, ys, paths)
end
end

function quick_plot_solve_paths(layout, graph)
xs, ys, paths = solve_positions(layout, graph)
function quick_plot_solve_paths(layout, graph; kwargs...)
xs, ys, paths = solve_positions(layout, graph; kwargs...)
quick_plot(graph, xs, ys, paths)
end
function quick_plot_solve_direct(layout, graph)
xs, ys, _ = solve_positions(layout, graph)
function quick_plot_solve_direct(layout, graph; kwargs...)
xs, ys, _ = solve_positions(layout, graph; kwargs...)
quick_plot(graph, xs, ys)
end

Expand All @@ -42,31 +42,36 @@ end
@plottest quick_plot(SimpleDiGraph(Edge.([1=>2, 2=>3])), [1,2,5], [1,2,3], paths) ref_filename true 0.05
end

function test_example(layout, graph_name, tol=0.05)
function test_example(layout, graph_name, tol=0.05; kwargs...)
@testset "$graph_name" begin
@testset "$graph_name direct" begin
graph = getfield(Examples, graph_name)
ref_filename = joinpath(@__DIR__, "references", string(typeof(layout)), "direct", "$graph_name.png")
filename = "$graph_name" * join("_" .* string.(keys(kwargs))) * ".png"
println(filename)
ref_filename = joinpath(@__DIR__, "references", string(typeof(layout)), "direct", filename)
mkpath(dirname(ref_filename))
@plottest quick_plot_solve_direct(layout, graph) ref_filename true tol
@plottest quick_plot_solve_direct(layout, graph; kwargs...) ref_filename true tol
end
@testset "$graph_name paths" begin
graph = getfield(Examples, graph_name)
ref_filename = joinpath(@__DIR__, "references", string(typeof(layout)), "paths", "$graph_name.png")
filename = "$graph_name" * join("_" .* string.(keys(kwargs))) * ".png"
println(filename)
ref_filename = joinpath(@__DIR__, "references", string(typeof(layout)), "paths", filename)
mkpath(dirname(ref_filename))
@plottest quick_plot_solve_paths(layout, graph) ref_filename true tol
@plottest quick_plot_solve_paths(layout, graph; kwargs...) ref_filename true tol
end
end
end

@testset "$layout Demos" for layout in (Zarate(),)
test_example(layout, :cross)
test_example(layout, :loop)
test_example(layout, :medium_pert)
test_example(layout, :sankey_3twos)
test_example(layout, :two_lines, 0.02)
test_example(layout, :xcross)
test_example(layout, :tree, 0.07)
# test_example(layout, :cross)
# test_example(layout, :loop)
# test_example(layout, :medium_pert)
# # test_example(layout, :sankey_3twos) # commented because
# test_example(layout, :two_lines, 0.02)
# test_example(layout, :xcross)
# test_example(layout, :tree, 0.07)
test_example(layout, :two_lines, 0.07; force_layer=[6=>3])
#test_example(layout, :large_depgraph) # too big
#test_example(layout, :extra_large_depgraph) # too big
end