diff --git a/.gitignore b/.gitignore index 9f5488988..f3365c6d3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ .pytest_cache .DS_Store .idea +.vscode .coverage .coverage.* __pycache__/ diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index f883c1e35..b245f2c1d 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -17,6 +17,7 @@ New Features: Bug Fixes: ^^^^^^^^^^ - Fix GAE computation for on-policy algorithms (off-by one for the last value) (thanks @Wovchena) +- Make ``make_vec_env`` support the ``env_kwargs`` argument when using an env ID str (@ManifoldFR) Deprecations: ^^^^^^^^^^^^^ @@ -25,6 +26,7 @@ Others: ^^^^^^^ - Improved typing coverage - Improved error messages for unsupported spaces +- Added ``.vscode`` to the gitignore Documentation: ^^^^^^^^^^^^^^ diff --git a/stable_baselines3/common/cmd_util.py b/stable_baselines3/common/cmd_util.py index 4169ae67e..8a9985e30 100644 --- a/stable_baselines3/common/cmd_util.py +++ b/stable_baselines3/common/cmd_util.py @@ -1,5 +1,4 @@ import os -import warnings from typing import Any, Callable, Dict, Optional, Type, Union import gym @@ -45,9 +44,7 @@ def make_vec_env( def make_env(rank): def _init(): if isinstance(env_id, str): - env = gym.make(env_id) - if len(env_kwargs) > 0: - warnings.warn("No environment class was passed (only an env ID) so ``env_kwargs`` will be ignored") + env = gym.make(env_id, **env_kwargs) else: env = env_id(**env_kwargs) if seed is not None: diff --git a/tests/test_utils.py b/tests/test_utils.py index 9450651f1..4f8b40085 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -65,6 +65,11 @@ def test_make_atari_env(env_id, n_envs, wrapper_kwargs): assert np.max(np.abs(reward)) < 1.0 +def test_vec_env_kwargs(): + env = make_vec_env("MountainCarContinuous-v0", n_envs=1, seed=0, env_kwargs={"goal_velocity": 0.11}) + assert env.get_attr("goal_velocity")[0] == 0.11 + + def test_custom_vec_env(tmp_path): """ Stand alone test for a special case (passing a custom VecEnv class) to avoid doubling the number of tests.