Skip to content

Commit

Permalink
Release 2.5.0 (#271)
Browse files Browse the repository at this point in the history
* Release 2.5.0

* Ignore mypy errors
  • Loading branch information
araffin authored Jan 27, 2025
1 parent e1ca24a commit c070fc2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docs/misc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
Changelog
==========

Release 2.5.0a0 (WIP)
Release 2.5.0 (2025-01-27)
--------------------------

Breaking Changes:
^^^^^^^^^^^^^^^^^
- Upgraded to PyTorch 2.3.0
- Dropped Python 3.8 support
- Upgraded to Stable-Baselines3 >= 2.5.0

New Features:
^^^^^^^^^^^^^
Expand Down
14 changes: 10 additions & 4 deletions sb3_contrib/common/envs/invalid_actions_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ def __init__(

space = spaces.Discrete(dim)
self.n_invalid_actions = n_invalid_actions
self.possible_actions = np.arange(space.n)
self.possible_actions = np.arange(space.n, dtype=int)
self.invalid_actions: list[int] = []
super().__init__(space=space, ep_length=ep_length)

def _choose_next_state(self) -> None:
self.state = self.action_space.sample()
# Randomly choose invalid actions that are not the current state
potential_invalid_actions = [i for i in self.possible_actions if i != self.state]
self.invalid_actions = np.random.choice(potential_invalid_actions, self.n_invalid_actions, replace=False).tolist()
self.invalid_actions = np.random.choice( # type: ignore[assignment]
potential_invalid_actions, self.n_invalid_actions, replace=False
).tolist()

def action_masks(self) -> list[bool]:
return [action not in self.invalid_actions for action in self.possible_actions]
Expand Down Expand Up @@ -72,7 +74,9 @@ def _choose_next_state(self) -> None:

# Randomly choose invalid actions that are not the current state
potential_invalid_actions = [i for i in self.possible_actions if i not in converted_state]
self.invalid_actions = np.random.choice(potential_invalid_actions, self.n_invalid_actions, replace=False).tolist()
self.invalid_actions = np.random.choice( # type: ignore[assignment]
potential_invalid_actions, self.n_invalid_actions, replace=False
).tolist()

def action_masks(self) -> list[bool]:
return [action not in self.invalid_actions for action in self.possible_actions]
Expand Down Expand Up @@ -113,7 +117,9 @@ def _choose_next_state(self) -> None:

# Randomly choose invalid actions that are not the current state
potential_invalid_actions = [i for i in self.possible_actions if i not in converted_state]
self.invalid_actions = np.random.choice(potential_invalid_actions, self.n_invalid_actions, replace=False).tolist()
self.invalid_actions = np.random.choice( # type: ignore[assignment]
potential_invalid_actions, self.n_invalid_actions, replace=False
).tolist()

def action_masks(self) -> list[bool]:
return [action not in self.invalid_actions for action in self.possible_actions]
2 changes: 1 addition & 1 deletion sb3_contrib/common/maskable/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _on_step(self) -> bool:
timesteps=self.evaluations_timesteps,
results=self.evaluations_results,
ep_lengths=self.evaluations_length,
**kwargs,
**kwargs, # type: ignore[arg-type]
)

mean_reward, std_reward = np.mean(episode_rewards), np.std(episode_rewards)
Expand Down
2 changes: 1 addition & 1 deletion sb3_contrib/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.0a0
2.5.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
packages=[package for package in find_packages() if package.startswith("sb3_contrib")],
package_data={"sb3_contrib": ["py.typed", "version.txt"]},
install_requires=[
"stable_baselines3>=2.4.0,<3.0",
"stable_baselines3>=2.5.0,<3.0",
],
description="Contrib package of Stable Baselines3, experimental code.",
author="Antonin Raffin",
Expand Down

0 comments on commit c070fc2

Please sign in to comment.