fix(rl): robust integer validation for utils.py (Fixes #953)#1000
Open
abdulwahabahmedkhanyusufzai wants to merge 2 commits intogoogle:mainfrom
Open
fix(rl): robust integer validation for utils.py (Fixes #953)#1000abdulwahabahmedkhanyusufzai wants to merge 2 commits intogoogle:mainfrom
abdulwahabahmedkhanyusufzai wants to merge 2 commits intogoogle:mainfrom
Conversation
Author
|
Hi @abheesht17. This PR resolves the AttributeError in is_positive_integer which is currently breaking compatibility for Python 3.11+ and NumPy users (Fixes #953). I've consolidated the previous work from #903 and #930 and added full unit tests. Could you please approve the workflows so the CI can verify the fix? Thanks! |
|
Just a note for maintainers, AI-generated pull requests (code + responses) with a clear lack of efforts have become a very prevalent issue with PyTorch and it appears this has spread to other open-source projects |
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.
This PR fixes an AttributeError crash encountered when using is_positive_integer with Numpy types (e.g., np.int64) or on Python 3.11+ where certain types lack the .is_integer() method.
This supersedes stale PRs #903 and #930. I have consolidated the fix and added the missing unit tests requested by maintainers.
Changes:
Implemented a safe is_integer_value helper that handles int, float, and numpy types correctly.
Added tests/rl/rl_utils_test.py to verify the fix across all types.
Related Issues:
Fixes #953
Resolves #903
Resolves #902
Test Plan
Created a new test file tests/rl/rl_utils_test.py. Verified locally with python3 -m unittest tests/rl/rl_utils_test.py.
Results:
✅ int (Standard) - Passed
✅ np.int64 (Numpy) - Passed (Previously crashed)
✅ float (Standard) - Passed
✅ bool - Rejected correctly