diff --git a/Project.toml b/Project.toml index c2ef6ce..2698ed1 100644 --- a/Project.toml +++ b/Project.toml @@ -6,20 +6,22 @@ version = "1.4.1" ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4" Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" -PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] ColorSchemes = "3.19 - 4" Colors = "0.12" Dates = "<0.0.1, 1" +PrecompileTools = "1" Printf = "<0.0.1, 1" Random = "<0.0.1, 1" Reexport = "1" -PrecompileTools = "1" +StableRNGs = "1" Statistics = "<0.0.1, 1" julia = "1.6" diff --git a/src/PlotUtils.jl b/src/PlotUtils.jl index e2b7161..520011e 100644 --- a/src/PlotUtils.jl +++ b/src/PlotUtils.jl @@ -8,7 +8,7 @@ using Dates @reexport using Colors import Base: getindex -import Random: MersenneTwister +import StableRNGs: StableRNG export ColorGradient, ColorPalette, diff --git a/src/adapted_grid.jl b/src/adapted_grid.jl index b672ea7..5ea80a8 100644 --- a/src/adapted_grid.jl +++ b/src/adapted_grid.jl @@ -16,7 +16,7 @@ function adapted_grid( minmax::Tuple{Number,Number}; max_recursions = 7, max_curvature = 0.01, - n_points = 31, + n_points = 31 ) if minmax[1] > minmax[2] throw(ArgumentError("interval must be given as (min, max)")) @@ -34,7 +34,7 @@ function adapted_grid( xs[end - 1] = xs[end] - (xs[end] - xs[end - 1]) / 4 # Wiggle interior points a bit to prevent aliasing and other degenerate cases - rng = MersenneTwister(1337) + rng = StableRNG(1337) rand_factor = 0.05 for i ∈ 2:(length(xs) - 1) xs[i] += 2rand_factor * (rand(rng) - 0.5) * (xs[i + 1] - xs[i - 1]) diff --git a/test/runtests.jl b/test/runtests.jl index 1e779c7..7029fbe 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -271,9 +271,15 @@ end @test fs |> extrema |> collect |> diff |> first > 1.9 end - let f = sinc, int = (0, 40) # JuliaPlots/Plots.jl/issues/3894 - xs, fs = adapted_grid(f, int) - @test length(xs) > 400 + let f = sinc, int = (-40, 40) # JuliaPlots/Plots.jl/issues/3894 + xs, fs = adapted_grid(sinc, int) + roots = vcat(int[1]:-1, 1:int[2]) + count_per_extrema = map(1:length(roots)-1) do idx + left = roots[idx]; right = roots[idx+1] + return count(x -> left < x < right, xs) + end + # check that we have at least 5 points for each extrema + @test all(count_per_extrema .>= 5) end end