-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SetTaskEnvUpdate when new env is a supertype (#2264)
Before, if the new environment was a subtype of the existing environment, the environment was not changed, even though it should be.
- Loading branch information
Showing
2 changed files
with
27 additions
and
2 deletions.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from garage.sampler import SetTaskUpdate | ||
|
||
from tests.fixtures.envs.dummy import DummyBoxEnv | ||
|
||
TEST_TASK = ['test_task'] | ||
|
||
|
||
class MTDummyEnv(DummyBoxEnv): | ||
|
||
def set_task(self, task): | ||
assert task == TEST_TASK | ||
|
||
|
||
class MTDummyEnvSubtype(MTDummyEnv): | ||
pass | ||
|
||
|
||
def test_set_task_update_with_subtype(): | ||
old_env = MTDummyEnvSubtype() | ||
env_update = SetTaskUpdate(MTDummyEnv, TEST_TASK, None) | ||
new_env = env_update(old_env) | ||
assert new_env is not old_env | ||
assert new_env is not None | ||
assert old_env is not None |