Skip to content

COMP: Replace np.bool with np.bool_#5402

Merged
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:release-5.4from
thewtex:numpy-bool_
Jun 16, 2025
Merged

COMP: Replace np.bool with np.bool_#5402
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:release-5.4from
thewtex:numpy-bool_

Conversation

@thewtex
Copy link
Copy Markdown
Member

@thewtex thewtex commented Jun 16, 2025

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

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
@thewtex thewtex requested a review from Copilot June 16, 2025 18:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 removed np.bool.

@github-actions github-actions bot added type:Compiler Compiler support or related warnings area:Python wrapping Python bindings for a class labels Jun 16, 2025
@hjmjohnson hjmjohnson merged commit a637501 into InsightSoftwareConsortium:release-5.4 Jun 16, 2025
17 checks passed
@thewtex thewtex deleted the numpy-bool_ branch June 16, 2025 21:39
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Python wrapping Python bindings for a class type:Compiler Compiler support or related warnings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants