Skip to content

Commit

Permalink
Tests and compat
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Nov 20, 2019
1 parent 89e152a commit ab2223f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ BayesianOptimization = "0.1.1"
GaussianProcesses = "0.9.0"
Juno = "0.7"
LatinHypercubeSampling = "1.2"
Parameters = "0.12"
Parameters = "0.11, 0.12"
RecipesBase = "0.7"
MacroTools = "0.5"
Lazy = "0.14"
Lazy = "0.13, 0.14"
julia = "1.0"

[extras]
Expand Down
1 change: 0 additions & 1 deletion src/samplers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ function macrobody(ex, params, candidates, sampler::Hyperband)
$(esc(ex.args[2]))
end
(::$typeof(costfun))($(esc(params[1])), $(esc(:state))) = $(esc(ex.args[2]))
@show methods(costfun)
hyperband($sampler, ho, costfun)
ho
end
Expand Down
21 changes: 20 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, Random
using Test, Random, Distributed
Random.seed!(0)
using Hyperopt, Plots

Expand All @@ -13,13 +13,32 @@ using Hyperopt, Plots
f(a,b,c=c)
end
@test minimum(hor)[2] < 300
@test length(hor.history) == 100
@test length(hor.results) == 100
@test all(hor.history) do h
all(hi in hor.candidates[i] for (i,hi) in enumerate(h))
end

horp = @phyperopt for i=100, sampler=RandomSampler(), a = LinRange(1,5,50), b = [true, false], c = exp10.(LinRange(-1,3,50))
# println(i, "\t", a, "\t", b, "\t", c)
# print(i, " ")
f(a,b,c=c)
end
@test minimum(horp)[2] < 300
@test length(horp.history) == 100
@test length(horp.results) == 100

addprocs(2)
@everywhere using Hyperopt
@everywhere f(a,b=true;c=10) = sum(@. 100 + (a-3)^2 + (b ? 10 : 20) + (c-100)^2)
horp = @phyperopt for i=100, sampler=RandomSampler(), a = LinRange(1,5,50), b = [true, false], c = exp10.(LinRange(-1,3,50))
# println(i, "\t", a, "\t", b, "\t", c)
# print(i, " ")
f(a,b,c=c)
end
@test minimum(horp)[2] < 300
@test length(horp.history) == 100
@test length(horp.results) == 100

hob = @hyperopt for i=100, sampler=BlueNoiseSampler(), a = LinRange(1,5,100), b = repeat([true, false],50), c = exp10.(LinRange(-1,3,100))
# println(i, "\t", a, "\t", b, "\t", c)
Expand Down

0 comments on commit ab2223f

Please sign in to comment.