Reject degenerate stochastic frameskip (n, n) at construction instead of crashing in step()#710
Open
teddytennant wants to merge 1 commit into
Conversation
a42e8ad to
4642385
Compare
Member
|
@teddytennant could you please rebase off main? |
The stochastic-frameskip validation in AtariEnv.__init__ only rejected reversed bounds (frameskip[0] > frameskip[1]), so an equal-bounds tuple such as (4, 4) passed validation. step() then calls self.np_random.integers(*self._frameskip), and numpy's integers() samples from the half-open interval [low, high); with low == high that range is empty and raises "ValueError: low >= high". The result was that construction and reset succeeded but the first step() died with a cryptic numpy error unrelated on its face to the frameskip argument. Tighten the check to frameskip[0] >= frameskip[1] so an empty range fails fast at construction, and fix the copy-paste error in the lower-bound message (it previously duplicated the bound-ordering text).
cc8d7b1 to
104f7a1
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Tighten the stochastic-frameskip validation in
AtariEnv.__init__so a degenerate equal-bounds tuple such as(4, 4)is rejected at construction, and fix a copy-paste error in one of the validation messages.Why
The validation only rejected reversed bounds (
frameskip[0] > frameskip[1]), so an equal-bounds tuple like(4, 4)passed. At step time,step()callsself.np_random.integers(*self._frameskip), and numpy'sintegers()samples from the half-open interval[low, high). Withlow == highthat range is empty and raisesValueError: low >= high.The upshot is that
AtariEnv("Pong", frameskip=(4, 4))andreset()succeed, then the very firststep()dies with a cryptic numpy error that doesn't obviously point back to the frameskip argument the user passed.Changing the comparison to
>=makes the invalid (empty) range fail fast at construction, consistent with the half-open sampling used instep(). I also fixed the message on theframeskip[0] <= 0branch, which duplicated the bound-ordering text instead of describing the positive-lower-bound requirement.Testing
Added the degenerate
(4, 4)case to the existingtest_frameskip_warningsparametrization, which asserts that construction raisesgymnasium.error.Error. The new case fails before this change (construction proceeds past validation) and passes after it.