Skip to content

Commit

Permalink
Merge pull request #199 from Holbormon/Fix-PGFPlotsX.jl-downstream-issue
Browse files Browse the repository at this point in the history
Tentative fix for PGFPlotsX.jl downstream issue
  • Loading branch information
BeastyBlacksmith authored May 15, 2024
2 parents f81f2e5 + 4c390a8 commit 9d26211
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 25 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ julia = "1.6"
Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -41,4 +42,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92"

[targets]
test = ["Gtk", "ImageMagick", "LinearAlgebra", "Markdown", "Plots", "Random", "SparseArrays", "StableRNGs", "Test", "VisualRegressionTests"]
test = ["Gtk", "ImageMagick", "LinearAlgebra", "Logging", "Markdown", "Plots", "Random", "SparseArrays", "StableRNGs", "Test", "VisualRegressionTests"]
Binary file modified assets/arc_chord_diagrams.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/ast_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/custom_nodeshapes_single.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/custom_nodeshapes_various.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/directed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/edgelabel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/funky_edge_and_marker_args.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/julia_dict_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/julia_type_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/light_graphs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/marker_properties.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/multigraphs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/random_3d_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/random_labelled_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/selfedges.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 11 additions & 9 deletions src/graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ more details.
nodeshape = repeat([nodeshape], length(x))
end
if !is3d
for i in 1:length(x)
for i in eachindex(x)
node_number =
i % length(nodeshape) == 0 ? length(nodeshape) : i % length(nodeshape)
node_weight =
Expand Down Expand Up @@ -591,7 +591,7 @@ more details.
# then all of the information in node_vec_vec_xy[i] can be summarised with three
# numbers describing the center and the radius of the circle.
node_perimeter_info = []
for i in 1:length(node_vec_vec_xy)
for i in eachindex(node_vec_vec_xy)
if nodeshape[i] == :circle
push!(
node_perimeter_info,
Expand Down Expand Up @@ -961,7 +961,7 @@ more details.
end

@series begin
num_edges_nodes := (length(edges_list[1]), length(node_vec_vec_xy)) # for debugging / tests
@debug num_edges_nodes := (length(edges_list[1]), length(node_vec_vec_xy)) # for debugging / tests

seriestype := if method in (:tree, :buchheim, :chorddiagram)
:curves
Expand Down Expand Up @@ -1063,7 +1063,7 @@ more details.
markeralpha := 0
aspect_ratio --> :equal
if length(names) == length(x)
annotations := [(x[i], y[i], names[i]) for i in 1:length(x)]
annotations := [(x[i], y[i], names[i]) for i in eachindex(x)]
end
@series begin
seriestype := :shape
Expand Down Expand Up @@ -1125,15 +1125,17 @@ more details.
seriestype := :scatter

colorbar_entry --> false
markersize --> 0
markeralpha --> 0
markersize := 0
markeralpha := 0
markerstrokesize := 0
!isnothing(edgelabel) && (annotations --> edge_label_array)
else
seriestype := :scatter

colorbar_entry --> false
markersize --> 0
markeralpha --> 0
markersize := 0
markeralpha := 0
markerstrokesize := 0
annotations --> [
edge_label_array
[
Expand All @@ -1146,7 +1148,7 @@ more details.
i % length(names),
)],
fontsize,
) for i in 1:length(x)
) for i in eachindex(x)
]
]
end
Expand Down
5 changes: 5 additions & 0 deletions test/functions.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
using Plots
using StableRNGs
using GraphRecipes
using GraphRecipes.Colors
using GraphRecipes.AbstractTrees
function random_labelled_graph()
n = 15
rng = StableRNG(1)
Expand Down
35 changes: 20 additions & 15 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using VisualRegressionTests
using AbstractTrees
using LinearAlgebra
using Logging
using GraphRecipes
using SparseArrays
using ImageMagick
Expand Down Expand Up @@ -41,8 +42,9 @@ cd(joinpath(@__DIR__, "..", "assets")) do

@plottest ast_example() "ast_example.png" popup = !isci() tol = itol()

@plottest julia_type_tree() "julia_type_tree.png" popup = !isci() tol = itol()

if !(v"1.6" < VERSION < v"1.7") # having Static.jl in the Manifest adds another type
@plottest julia_type_tree() "julia_type_tree.png" popup = !isci() tol = itol()
end
@plottest julia_dict_tree() "julia_dict_tree.png" popup = !isci() tol = itol()

@plottest funky_edge_and_marker_args() "funky_edge_and_marker_args.png" popup =
Expand Down Expand Up @@ -79,20 +81,23 @@ end
@test s == [2, 3, 3, 4]
@test d == [3, 2, 4, 3]
@test all(w .≈ 1)
pl = graphplot(g)
@test first(pl.series_list)[:extra_kwargs][:num_edges_nodes] == (2, 7)

add_edge!(g, 6, 7)
@test g.ne == 3
pl = graphplot(g)
@test first(pl.series_list)[:extra_kwargs][:num_edges_nodes] == (3, 7)

# old behavior (see issue), can be recovered using `trim=true`
g = SimpleGraph(7)
add_edge!(g, 2, 3)
add_edge!(g, 3, 4)
pl = graphplot(g; trim = true)
@test first(pl.series_list)[:extra_kwargs][:num_edges_nodes] == (2, 4)
with_logger(ConsoleLogger(stderr, Logging.Debug)) do
pl = graphplot(g)
@test first(pl.series_list)[:extra_kwargs][:num_edges_nodes] == (2, 7)

add_edge!(g, 6, 7)
@test g.ne == 3
pl = graphplot(g)
@test first(pl.series_list)[:extra_kwargs][:num_edges_nodes] == (3, 7)

# old behavior (see issue), can be recovered using `trim=true`
g = SimpleGraph(7)
add_edge!(g, 2, 3)
add_edge!(g, 3, 4)
pl = graphplot(g; trim = true)
@test first(pl.series_list)[:extra_kwargs][:num_edges_nodes] == (2, 4)
end
end

@testset "180" begin
Expand Down

0 comments on commit 9d26211

Please sign in to comment.