Skip to content

Commit

Permalink
change fakedata rng in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Jul 23, 2021
1 parent cd06648 commit cc1a328
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ function convert_to_polar(theta, r, r_extrema = ignorenan_extrema(r))
x, y
end

function fakedata(sz...; rng=Random.GLOBAL_RNG(PLOTS_SEED))
fakedata(sz::Int...) = fakedata(Random.seed!(PLOTS_SEED), sz...)

function fakedata(rng::AbstractRNG, sz...)
y = zeros(sz...)
for r in 2:size(y,1)
y[r,:] = 0.95 * vec(y[r-1,:]) + randn(rng, size(y,2))
Expand Down
3 changes: 2 additions & 1 deletion test/imgcomp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function replace_rand!(ex::Expr)
for arg in ex.args
replace_rand!(arg)
end
if ex.head === :call && ex.args[1] (:rand, :randn)
if ex.head === :call && ex.args[1] (:rand, :randn, :(Plots.fakedata))
pushfirst!(ex.args, ex.args[1])
ex.args[2] = :rng
end
Expand Down Expand Up @@ -41,6 +41,7 @@ function image_comparison_tests(
expr = Expr(:block)
append!(expr.args, example.exprs)
fix_rand!(expr)
@debug expr
eval(expr)
png(fn)
end
Expand Down

0 comments on commit cc1a328

Please sign in to comment.