Skip to content

Commit

Permalink
Merge pull request #162 from t-bltg/rng
Browse files Browse the repository at this point in the history
Use StableRNGs
  • Loading branch information
t-bltg authored Jul 23, 2021
2 parents 8d3e491 + 5fea4d4 commit 4cf8e08
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 17 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"

[targets]
test = ["VisualRegressionTests", "LinearAlgebra", "Plots", "ImageMagick", "Random", "SparseArrays", "Test", "Markdown"]
test = ["VisualRegressionTests", "LinearAlgebra", "Plots", "ImageMagick", "Random", "SparseArrays", "Test", "Markdown", "StableRNGs"]
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/readme_julia_logo_pun.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.
2 changes: 1 addition & 1 deletion test/figures.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Random
using StableRNGs
using VisualRegressionTests
using LinearAlgebra
using SparseArrays
Expand Down
29 changes: 15 additions & 14 deletions test/functions.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
function random_labelled_graph()
n = 15
Random.seed!(1)
A = Float64[ rand() < 0.5 ? 0 : rand() for i=1:n, j=1:n]
rng = StableRNG(1)
A = Float64[ rand(rng) < 0.5 ? 0 : rand(rng) for i=1:n, j=1:n]
for i=1:n
A[i, 1:i-1] = A[1:i-1, i]
A[i, i] = 0
end
x = rand(n)
y = rand(n)
z = rand(n)
x = rand(rng,n)
y = rand(rng,n)
z = rand(rng,n)
p = graphplot(A,
nodesize = 0.2,
node_weights = 1:n,
Expand Down Expand Up @@ -74,7 +74,8 @@ function multigraphs()
end

function arc_chord_diagrams()
adjmat = Symmetric(sparse(rand(0:1,8,8)))
rng = StableRNG(2)
adjmat = Symmetric(sparse(rand(rng,0:1,8,8)))
plot(
graphplot(adjmat,
method=:chorddiagram,
Expand All @@ -93,15 +94,16 @@ end

function marker_properties()
N = 8
g = barabasi_albert(N, 1; seed = 42)
seed = 42
g = barabasi_albert(N, 1; seed=seed)
weights = [length(neighbors(g, i)) for i in 1:nv(g)]
Random.seed!(42)
rng = StableRNG(seed)
graphplot(g, curvature_scalar=0,
node_weights=weights, nodesize=0.25,
linecolor=:gray,
linewidth=2.5,
nodeshape=:circle,
node_z=rand(N), markercolor=:viridis,
node_z=rand(rng,N), markercolor=:viridis,
nodestrokewidth=1.5,
markerstrokestyle=:solid,
markerstrokealpha=1.0,
Expand Down Expand Up @@ -157,8 +159,8 @@ function diamond_nodeshape_wh(x_i, y_i, h, w)
end

function custom_nodeshapes_single()
Random.seed!(6)
g = rand(5,5)
rng = StableRNG(6)
g = rand(rng,5,5)
g[g .> 0.5] .= 0
for i in 1:5
g[i,i] = 0
Expand All @@ -167,8 +169,8 @@ function custom_nodeshapes_single()
end

function custom_nodeshapes_various()
Random.seed!(6)
g = rand(5,5)
rng = StableRNG(6)
g = rand(rng,5,5)
g[g .> 0.5] .= 0
for i in 1:5
g[i,i] = 0
Expand All @@ -177,7 +179,6 @@ function custom_nodeshapes_various()
end

function funky_edge_and_marker_args()
Random.seed!(6)
n = 5
g = SimpleDiGraph(n)

Expand Down
2 changes: 1 addition & 1 deletion test/generate_figures.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Random
using StableRNGs
using LinearAlgebra
using SparseArrays
using GraphRecipes
Expand Down

0 comments on commit 4cf8e08

Please sign in to comment.