Hyperopt.jl icon indicating copy to clipboard operation
Hyperopt.jl copied to clipboard

error when there is only one param to optimize

Open norci opened this issue 2 years ago • 1 comments

julia> @hyperopt for i=10, a=LinRange(1,10,10)
       a
       end
ERROR: UndefVarError: a not defined
Stacktrace:
 [1] macro expansion
   @ ./REPL[33]:2 [inlined]
 [2] var"#395###hyperopt_objective#281"(i::Int64, state::Float64)
   @ Main /julia/dev/Hyperopt.jl/src/Hyperopt.jl:152

it's caused by function flamingo(i, state) and function flamingo((i, a)...) are the same.

shall we change state to a keyword argument? or document this limitation? I think this is a rare case.

julia> @expand @hyperopt for i=10, a=LinRange(1,10,10)
       a
       end
:(Hyperopt.optimize(begin
          #= /julia/dev/Hyperopt.jl/src/Hyperopt.jl:179 =#
          (wildebeest, eagle) = (begin
                      #= /julia/dev/Hyperopt.jl/src/Hyperopt.jl:147 =#
                      function flamingo((i, a)...)
                          #= /julia/dev/Hyperopt.jl/src/Hyperopt.jl:147 =#
                          #= /julia/dev/Hyperopt.jl/src/Hyperopt.jl:148 =#
                          state = nothing
                          #= /julia/dev/Hyperopt.jl/src/Hyperopt.jl:149 =#
                          begin
                              #= REPL[32]:2 =#
                              a
                          end
                      end
                      #= /julia/dev/Hyperopt.jl/src/Hyperopt.jl:151 =#
                      function flamingo(i, state)
                          #= /julia/dev/Hyperopt.jl/src/Hyperopt.jl:151 =#
                          #= /julia/dev/Hyperopt.jl/src/Hyperopt.jl:152 =#
                          begin
                              #= REPL[32]:2 =#
                              a
                          end
                      end
                  end, 10)

norci avatar Nov 11 '21 12:11 norci

Would it be hard to make state work as a keyword argument? Seems to be something that is used for the hyperband stuff (based on what tests failed when I took it away), but I haven't really looked in to that code so I'm not sure exactly what is going on?

albheim avatar Feb 10 '22 10:02 albheim