Skip to content

Fix np.bool8 error for NumPy 1.24+ compatibility #637

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kohankhaki
Copy link

Fix: Add compatibility patch for deprecated np.bool8 in NumPy ≥1.24

Summary

This PR addresses a compatibility issue with newer versions of NumPy (1.24+) by defining np.bool8 as an alias to np.bool_ when it is missing. This fixes runtime errors in environments that still reference np.bool8.

Problem

When using NumPy ≥1.24, the following error is raised:

AttributeError: module 'numpy' has no attribute 'bool8'

This is because of the removal of the np.bool8 alias, which some environments or wrappers (e.g., from gym-games or older Gym integrations) still use.

Solution

This PR adds the following patch at runtime:

import numpy as np

if not hasattr(np, 'bool8'):
    np.bool8 = np.bool_

References

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.

1 participant