forked from openai/retro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix experimental normalize reward wrapper (openai#277)
Co-authored-by: raphajaner <[email protected]>
- Loading branch information
1 parent
b4caf9d
commit 4b5abb6
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
"""Test suite for NormalizeRewardV0.""" | ||
import numpy as np | ||
|
||
from gymnasium.core import ActType | ||
from gymnasium.experimental.wrappers import NormalizeRewardV0 | ||
from tests.testing_env import GenericTestEnv | ||
|
||
|
||
def _make_reward_env(): | ||
"""Function that returns a `GenericTestEnv` with reward=1.""" | ||
|
||
def step_func(self, action: ActType): | ||
return self.observation_space.sample(), 1.0, False, False, {} | ||
|
||
return GenericTestEnv(step_func=step_func) | ||
|
||
|
||
def test_normalize_reward_wrapper(): | ||
"""Tests that the NormalizeReward does not throw an error.""" | ||
# TODO: Functional correctness should be tested | ||
env = _make_reward_env() | ||
wrapped_env = NormalizeRewardV0(env) | ||
wrapped_env.reset() | ||
_, reward, _, _, _ = wrapped_env.step(None) | ||
assert np.ndim(reward) == 0 | ||
env.close() |