Skip to content

Commit

Permalink
fix warnings fired from PyCall
Browse files Browse the repository at this point in the history
  • Loading branch information
ozanarkancan committed Mar 20, 2019
1 parent 88f17be commit 6328fe5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Gym.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include("env.jl")
Shows available environments
"""
function show_available_envs()
println(map(x->x[:id], gym.envs[:registry][:all]()))
println(map(x->x.id, gym.envs.registry.all()))
end

export GymEnv, reset!, step!, render, close, seed!
Expand Down
32 changes: 16 additions & 16 deletions src/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ end
function GymEnv(id::String)
gymenv = nothing
try
gymenv = gym[:make](id)
gymenv = gym.make(id)
catch e
error("Error received during the initialization of $id\n$e")
end

spec = Spec(gymenv[:spec][:id],
gymenv[:spec][:trials],
gymenv[:spec][:reward_threshold],
gymenv[:spec][:nondeterministic],
gymenv[:spec][:tags],
gymenv[:spec][:max_episode_steps],
gymenv[:spec][:timestep_limit]
spec = Spec(gymenv.spec.id,
gymenv.spec.trials,
gymenv.spec.reward_threshold,
gymenv.spec.nondeterministic,
gymenv.spec.tags,
gymenv.spec.max_episode_steps,
gymenv.spec.timestep_limit
)
action_space = julia_space(gymenv[:action_space])
observation_space = julia_space(gymenv[:observation_space])
action_space = julia_space(gymenv.action_space)
observation_space = julia_space(gymenv.observation_space)

env = GymEnv(id, spec, action_space,
observation_space, gymenv[:reward_range], gymenv)
observation_space, gymenv.reward_range, gymenv)
return env
end

reset!(env::GymEnv) = env.gymenv[:reset]()
reset!(env::GymEnv) = env.gymenv.reset()
function render(env::GymEnv; mode="human")
env.gymenv[:render](mode)
env.gymenv.render(mode)
end

function step!(env::GymEnv, action)
ob, reward, done, information = env.gymenv[:step](action)
ob, reward, done, information = env.gymenv.step(action)
return ob, reward, done, information
end

close!(env::GymEnv) = env.gymenv[:close]()
close!(env::GymEnv) = env.gymenv.close()

seed!(env::GymEnv, seed=nothing) = env.gymenv[:seed](seed)
seed!(env::GymEnv, seed=nothing) = env.gymenv.seed(seed)
8 changes: 4 additions & 4 deletions src/spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ end
sample(s::TupleS) = map(sample, s.spaces)

function julia_space(ps)
class_name = ps[:__class__][:__name__]
class_name = ps.__class__.__name__
if class_name == "Discrete"
return DiscreteS(ps[:n])
return DiscreteS(ps.n)
elseif class_name == "Box"
return BoxS(ps[:low], ps[:high], ps[:shape])
return BoxS(ps.low, ps.high, ps.shape)
elseif class_name == "Tuple"
spaces = [julia_space(s) for s in ps[:spaces]]
spaces = [julia_space(s) for s in ps.spaces]
return TupleS((spaces...,))
else
error("$class_name has not been supported yet")
Expand Down

0 comments on commit 6328fe5

Please sign in to comment.