Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the observations variable in the evaluation util to avoid shadowing #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/misc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Changelog
==========
- Renamed environment output observations in ``evaluate_policy`` to prevent shadowing the input observations during callbacks (@npit)

Release 1.8.0 (2023-04-07)
--------------------------
Expand Down Expand Up @@ -418,4 +419,4 @@ Contributors:
-------------

@ku2482 @guyk1971 @minhlong94 @ayeright @kronion @glmcdona @cyprienc @sgillen @Gregwar @rnederstigt @qgallouedec
@mlodel @CppMaster @burakdmb @honglu2875 @ZikangXiong @AlexPasqua @jonasreiher
@mlodel @CppMaster @burakdmb @honglu2875 @ZikangXiong @AlexPasqua @jonasreiher @npit
3 changes: 2 additions & 1 deletion sb3_contrib/common/maskable/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def evaluate_policy(
actions, states = model.predict(
observations, state=states, episode_start=episode_starts, deterministic=deterministic
)
observations, rewards, dones, infos = env.step(actions)
new_observations, rewards, dones, infos = env.step(actions)
current_rewards += rewards
current_lengths += 1
for i in range(n_envs):
Expand All @@ -116,6 +116,7 @@ def evaluate_policy(

if callback is not None:
callback(locals(), globals())
observations = new_observations

if dones[i]:
if is_monitor_wrapped:
Expand Down