Monkey-patch np.bool = bool

This commit is contained in:
Antonin Raffin 2022-12-19 13:20:48 +01:00
parent 68a40e0940
commit 213b06b0c6
No known key found for this signature in database
GPG key ID: B8B48F65CAD6232C
2 changed files with 7 additions and 1 deletions

View file

@ -77,7 +77,7 @@ setup(
package_data={"stable_baselines3": ["py.typed", "version.txt"]}, package_data={"stable_baselines3": ["py.typed", "version.txt"]},
install_requires=[ install_requires=[
"gym==0.21", # Fixed version due to breaking changes in 0.22 "gym==0.21", # Fixed version due to breaking changes in 0.22
"numpy<1.24", # Required for gym==0.21 "numpy",
"torch>=1.11", "torch>=1.11",
'typing_extensions>=4.0,<5; python_version < "3.8.0"', 'typing_extensions>=4.0,<5; python_version < "3.8.0"',
# For saving models # For saving models

View file

@ -1,5 +1,7 @@
import os import os
import numpy as np
from stable_baselines3.a2c import A2C from stable_baselines3.a2c import A2C
from stable_baselines3.common.utils import get_system_info from stable_baselines3.common.utils import get_system_info
from stable_baselines3.ddpg import DDPG from stable_baselines3.ddpg import DDPG
@ -9,6 +11,10 @@ from stable_baselines3.ppo import PPO
from stable_baselines3.sac import SAC from stable_baselines3.sac import SAC
from stable_baselines3.td3 import TD3 from stable_baselines3.td3 import TD3
# Small monkey patch so gym 0.21 is compatible with numpy >= 1.24
# TODO: remove when upgrading to gym 0.26
np.bool = bool
# Read version from file # Read version from file
version_file = os.path.join(os.path.dirname(__file__), "version.txt") version_file = os.path.join(os.path.dirname(__file__), "version.txt")
with open(version_file) as file_handler: with open(version_file) as file_handler: