COMP: Replace np.bool with np.bool_#5402
Merged
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:release-5.4from Jun 16, 2025
Merged
COMP: Replace np.bool with np.bool_#5402hjmjohnson merged 1 commit intoInsightSoftwareConsortium:release-5.4from
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:release-5.4from
Conversation
For: E AttributeError: module 'numpy' has no attribute 'bool'. E `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. E The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: E https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an AttributeError by replacing the deprecated np.bool alias with the correct NumPy scalar type np.bool_ to maintain compatibility with NumPy ≥1.20.
- Updated the C-type initializer for boolean to use
np.bool_instead of the removednp.bool.
dzenanz
approved these changes
Jun 16, 2025
hjmjohnson
approved these changes
Jun 16, 2025
a637501
into
InsightSoftwareConsortium:release-5.4
17 checks passed
rakino
pushed a commit
to rakino/guix-mirror
that referenced
this pull request
Aug 11, 2025
Insight Toolkit (ITK) Python module fails to import due to: AttributeError: module 'numpy' has no attribute 'bool' Implement the fix from here: <InsightSoftwareConsortium/ITK#5402> While ITK's test suite is disabled for good reason, we can test that the Python module imports successfully. Importing the Python module requires NumPy. It is added as a native-input instead of a propagated-input because the "out" output is unrelated to Python. * gnu/packages/image-processing.scm (insight-toolkit)[arguments]: Remove '#tests? #f'. Add #:imported-modules and #:modules. <#:phases>: Delete 'check. Add 'fix-numpy-bool and 'python-sanity-check. [native-inputs]: Add python-numpy. (insight-toolkit-legacy)[arguments]: Remove inherited phase 'python-sanity-check. [native-inputs]: Remove inherited python-numpy. Change-Id: Ia6d14c22cbea9cd9877da36f8f72e2e34ff8a8a6 Signed-off-by: Andreas Enge <andreas@enge.fr>
rakino
pushed a commit
to rakino/guix-mirror
that referenced
this pull request
Aug 14, 2025
Insight Toolkit (ITK) Python module fails to import due to: AttributeError: module 'numpy' has no attribute 'bool' Implement the fix from here: <InsightSoftwareConsortium/ITK#5402> While ITK's test suite is disabled for good reason, we can test that the Python module imports successfully. Importing the Python module requires NumPy. It is added as a native-input instead of a propagated-input because the "out" output is unrelated to Python. * gnu/packages/image-processing.scm (insight-toolkit)[arguments]: Remove '#tests? #f'. Add #:imported-modules and #:modules. <#:phases>: Delete 'check. Add 'fix-numpy-bool and 'python-sanity-check. [native-inputs]: Add python-numpy. (insight-toolkit-legacy)[arguments]: Remove inherited phase 'python-sanity-check. [native-inputs]: Remove inherited python-numpy. Change-Id: Ia6d14c22cbea9cd9877da36f8f72e2e34ff8a8a6 Signed-off-by: Andreas Enge <andreas@enge.fr>
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.
For:
E AttributeError: module 'numpy' has no attribute 'bool'.
E
np.boolwas a deprecated alias for the builtinbool. To avoid this error in existing code, useboolby itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, usenp.bool_here.E The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
E https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations