JuliaML / OpenAIGym.jl

OpenAI's Gym binding for Julia
Other
105 stars 19 forks source link

Julia thinks IntervalSet is iterator? #7

Closed baggepinnen closed 7 years ago

baggepinnen commented 7 years ago

I am suddenly having issues with the following piece of code from iterators.jl

    if !(a in A)
        warn("action $a is not in $A")
        # a = rand(A)
    end
    @assert a in A

The code a in A generates the error

julia> 0 in A
ERROR: MethodError: no method matching start(::LearnBase.IntervalSet{Array{Float64,1}})
Closest candidates are:
  start(::SimpleVector) at essentials.jl:170
  start(::Base.MethodList) at reflection.jl:258
  start(::IntSet) at intset.jl:184
  ...
 in mapreduce_sc_impl(::Base.Predicate{Base.##212#213{Int64}}, ::Base.#|, ::LearnBase.IntervalSet{Array{Float64,1}}) at ./reduce.jl:197
 in in(::Int64, ::LearnBase.IntervalSet{Array{Float64,1}}) at ./reduce.jl:481

Which I interpret as Julia not being aware that A is a set-type, and thus thinks it should initiate an iteration.

baggepinnen commented 7 years ago

Ok, issue found. The problem was that a in my case was a 1x1 Matrix when running the code, and a scalar when testing in the REPL, when the correct type to use was a 1-Vector. Tricky error message :P