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

[rlib] Independent bound for each dimension AssertionError #16845 #16860

Merged
merged 2 commits into from
Jul 10, 2021

Conversation

frenkowski
Copy link
Contributor

Why are these changes needed?

Restored support for Box space type with independent bound for each dimension.

Related issue number

#16845
cc @richardliaw

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Restored support for Box space type with independent bound for each dimension.
@@ -241,8 +241,8 @@ def get_action_dist(
if action_space.dtype.name.startswith("int"):
low_ = np.min(action_space.low)
high_ = np.max(action_space.high)
assert np.all(action_space.low == low_)
assert np.all(action_space.high == high_)
assert np.all(action_space.low >= low_)
Copy link
Contributor

@mvindiola1 mvindiola1 Jul 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @frenkowski and @richardliaw,

I am looking at these assertions and wondering if they are even needed now. How they would be false? I cannot think of how but I am probably missing something. Do you have an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!
If you have a Box with independent bound for each dimension (e.g. Box(low=np.array([-1.0, -2.0]), high=np.array([2.0, 4.0]), dtype=np.float32)), the lowest value is -2.0.
Therefore in this case the assertion fails, given that -1.0 != -2.0 (but -1.0 >= -2.0).
The same obviously applies to the highest value.

Copy link
Contributor

@mvindiola1 mvindiola1 Jul 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @frenkowski,

Thank you for the reply. I think I may not have been clear. I agree that the original issue you posted is a bug what I am wondering is after your fix would it ever assert.

You defined low_ to be np.min(action_space.low) then you have an assertion to check that all values in action_space.low are greater than our equal to that value. By construction that is the lowest value so how could that ever be false?

I am not saying the logic of your solution is wrong I am just wondering what kind of issue that new assertion could catch.

Edit: I guess what I am wondering is if we can just remove the assertions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvindiola1 I apologize for the misunderstanding!
I totally agree with you, we can just remove the assertions regardless of the bug.
I suggested that change because I sincerely do not know the logic of the author with respect to the original assertion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is up to @richardliaw as to which approach he prefers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, agree with @mvindiola1 that we can just remove the assertions!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvindiola1 @richardliaw I removed the assertions with the new commit

@richardliaw richardliaw merged commit 01c533c into ray-project:master Jul 10, 2021
@richardliaw
Copy link
Contributor

@frenkowski ah! sorry about the late approval, and thanks a bunch for the ping!

jiaodong pushed a commit that referenced this pull request Jul 11, 2021
…6860)

* Fix AssertionError for Box space type

Restored support for Box space type with independent bound for each dimension.

* Removed unnecessary assertion for Box space type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants