Fix NumPy Deprecation Warning for np.bool Usage in attention.py #50
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.
Problem Description
The glide_text2im package currently uses np.bool in attention.py, which has been deprecated since NumPy 1.20. This results in a FutureWarning when using the package and eventually leads to an AttributeError in environments with NumPy versions that have fully removed the np.bool alias.
Proposed Solution
This pull request replaces all instances of np.bool with np.bool_ in the attention.py file. The np.bool_ data type is the recommended replacement for np.bool and is not deprecated. This change ensures compatibility with current and future versions of NumPy without altering the functionality of the glide_text2im package.
Justification
Using np.bool_ ensures that the package remains functional and free of deprecation warnings and errors with NumPy 1.20 and later. This update is necessary to maintain the package's usability in current and future Python environments, fostering a smoother user experience and compatibility with the wider Python ecosystem.
Testing
The modifications have been tested locally to verify that the FutureWarning is resolved and that the glide_text2im package functions as expected with the change. All existing tests pass, and no new functionality has been introduced, minimizing the risk of side effects.
I look forward to your feedback on this pull request. Thank you for maintaining the glide_text2im package and for considering this update to ensure its continued compatibility and performance.