forked from facebookresearch/CompilerGym
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add backwards compatibility for Reward.id.
We don't want the change introduced in facebookresearch#565 to immediately break existing user code. Instead, add a workaround that emits a deprecation warning so that users can update their code upon the next release. Issue facebookresearch#381.
- Loading branch information
1 parent
885a9ea
commit b1aa2e5
Showing
4 changed files
with
81 additions
and
8 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
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,25 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
"""Unit tests for compiler_gym.spaces.Reward.""" | ||
import pytest | ||
|
||
from compiler_gym.spaces import Reward | ||
from tests.test_main import main | ||
|
||
|
||
def test_reward_id_backwards_compatibility(): | ||
"""Test that Reward.id is backwards compatible with Reward.name. | ||
See: github.com/facebookresearch/CompilerGym/issues/381 | ||
""" | ||
with pytest.warns(DeprecationWarning, match="renamed `name`"): | ||
reward = Reward(id="foo") | ||
|
||
assert reward.id == "foo" | ||
assert reward.name == "foo" | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |