Skip to content

Commit

Permalink
Merge pull request #104 from sony/feature/20230714-fix-examples
Browse files Browse the repository at this point in the history
Fix Deprecation error when using PendulumEnv
  • Loading branch information
sbsekiguchi committed Jul 21, 2023
2 parents 031f7fe + 6d79bcb commit 81c1833
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions examples/evaluate_trained_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2020,2021 Sony Corporation.
# Copyright 2021 Sony Group Corporation.
# Copyright 2021,2022,2023 Sony Group Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,10 @@


def build_env():
env = gym.make('Pendulum-v0')
try:
env = gym.make('Pendulum-v0')
except gym.error.DeprecatedEnv:
env = gym.make('Pendulum-v1')
env = NumpyFloat32Env(env)
env = ScreenRenderEnv(env)
return env
Expand Down
7 changes: 5 additions & 2 deletions examples/training_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2020,2021 Sony Corporation.
# Copyright 2021 Sony Group Corporation.
# Copyright 2021,2022,2023 Sony Group Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,10 @@


def build_env(seed=None):
env = gym.make('Pendulum-v0')
try:
env = gym.make('Pendulum-v0')
except gym.error.DeprecatedEnv:
env = gym.make('Pendulum-v1')
env = NumpyFloat32Env(env)
env = ScreenRenderEnv(env)
env.seed(seed)
Expand Down
7 changes: 5 additions & 2 deletions examples/writer_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2020,2021 Sony Corporation.
# Copyright 2021 Sony Group Corporation.
# Copyright 2021,2022,2023 Sony Group Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,7 +48,10 @@ def _create_monitor_series(self, names):


def build_env(seed=None):
env = gym.make('Pendulum-v0')
try:
env = gym.make('Pendulum-v0')
except gym.error.DeprecatedEnv:
env = gym.make('Pendulum-v1')
env = NumpyFloat32Env(env)
env.seed(seed)
return env
Expand Down

0 comments on commit 81c1833

Please sign in to comment.