Skip to content

Conversation

@bug39
Copy link

@bug39 bug39 commented Dec 17, 2025

Remove .is_integer() call as int.is_integer() was only added in Python 3.12.
pyproject.toml specifies: requires-python = ">=3.11", yet according to https://docs.python.org/3.12/library/stdtypes.html int.is_integer() was only added in Python 3.12 for duck-type compatibility with `float.is_integer()

Resolves #<902>

Removes .is_integer() call as 'int' object has no attribute'is_integer.'
Copy link
Collaborator

@wang2yn84 wang2yn84 left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! Let's try the following and add a unit test here.

def is_integer_value(x):
return isinstance(x, int) or (
isinstance(x, float) and x.is_integer()
)

Added is_integer_value helper and use it within is_positive_integer; Excludes booleans as a subclass of int
@bug39
Copy link
Author

bug39 commented Dec 18, 2025

Thank you for the PR! Let's try the following and add a unit test here.

def is_integer_value(x): return isinstance(x, int) or ( isinstance(x, float) and x.is_integer() )

Addressed by adding an is_integer_value helper function, also adding a check that x is not a boolean (is_instance(bool, int) would return True). I'm not sure if you wanted me to include an assert block. Please let me know!

@wang2yn84
Copy link
Collaborator

Thank you for the update. Can you add a simple test cover various data types to https://github.com/google/tunix/blob/main/tests/rl/rl_utils_test.py?

@wang2yn84
Copy link
Collaborator

And also please squash the commits before merge, thank you!

@rajasekharporeddy
Copy link
Collaborator

Hi @bug39, Could you please add a sample test and squash the commits?

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.

3 participants