Skip to content

Commit 6328fe5

Browse files
committed
fix warnings fired from PyCall
1 parent 88f17be commit 6328fe5

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/Gym.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ include("env.jl")
1616
Shows available environments
1717
"""
1818
function show_available_envs()
19-
println(map(x->x[:id], gym.envs[:registry][:all]()))
19+
println(map(x->x.id, gym.envs.registry.all()))
2020
end
2121

2222
export GymEnv, reset!, step!, render, close, seed!

src/env.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,37 @@ end
1313
function GymEnv(id::String)
1414
gymenv = nothing
1515
try
16-
gymenv = gym[:make](id)
16+
gymenv = gym.make(id)
1717
catch e
1818
error("Error received during the initialization of $id\n$e")
1919
end
2020

21-
spec = Spec(gymenv[:spec][:id],
22-
gymenv[:spec][:trials],
23-
gymenv[:spec][:reward_threshold],
24-
gymenv[:spec][:nondeterministic],
25-
gymenv[:spec][:tags],
26-
gymenv[:spec][:max_episode_steps],
27-
gymenv[:spec][:timestep_limit]
21+
spec = Spec(gymenv.spec.id,
22+
gymenv.spec.trials,
23+
gymenv.spec.reward_threshold,
24+
gymenv.spec.nondeterministic,
25+
gymenv.spec.tags,
26+
gymenv.spec.max_episode_steps,
27+
gymenv.spec.timestep_limit
2828
)
29-
action_space = julia_space(gymenv[:action_space])
30-
observation_space = julia_space(gymenv[:observation_space])
29+
action_space = julia_space(gymenv.action_space)
30+
observation_space = julia_space(gymenv.observation_space)
3131

3232
env = GymEnv(id, spec, action_space,
33-
observation_space, gymenv[:reward_range], gymenv)
33+
observation_space, gymenv.reward_range, gymenv)
3434
return env
3535
end
3636

37-
reset!(env::GymEnv) = env.gymenv[:reset]()
37+
reset!(env::GymEnv) = env.gymenv.reset()
3838
function render(env::GymEnv; mode="human")
39-
env.gymenv[:render](mode)
39+
env.gymenv.render(mode)
4040
end
4141

4242
function step!(env::GymEnv, action)
43-
ob, reward, done, information = env.gymenv[:step](action)
43+
ob, reward, done, information = env.gymenv.step(action)
4444
return ob, reward, done, information
4545
end
4646

47-
close!(env::GymEnv) = env.gymenv[:close]()
47+
close!(env::GymEnv) = env.gymenv.close()
4848

49-
seed!(env::GymEnv, seed=nothing) = env.gymenv[:seed](seed)
49+
seed!(env::GymEnv, seed=nothing) = env.gymenv.seed(seed)

src/spaces.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ end
3535
sample(s::TupleS) = map(sample, s.spaces)
3636

3737
function julia_space(ps)
38-
class_name = ps[:__class__][:__name__]
38+
class_name = ps.__class__.__name__
3939
if class_name == "Discrete"
40-
return DiscreteS(ps[:n])
40+
return DiscreteS(ps.n)
4141
elseif class_name == "Box"
42-
return BoxS(ps[:low], ps[:high], ps[:shape])
42+
return BoxS(ps.low, ps.high, ps.shape)
4343
elseif class_name == "Tuple"
44-
spaces = [julia_space(s) for s in ps[:spaces]]
44+
spaces = [julia_space(s) for s in ps.spaces]
4545
return TupleS((spaces...,))
4646
else
4747
error("$class_name has not been supported yet")

0 commit comments

Comments
 (0)