Skip to content

[Compatibility Issue] np.bool removed in NumPy 1.24 — use bool instead #82

Description

@xyf5432

Affected File

causallib/preprocessing/filters.py:255

Current Code

is_removed = np.zeros(X.shape[1], dtype=np.bool)

Root Cause

np.bool was deprecated in NumPy 1.20 and fully removed in NumPy 1.24 (2022-12). In NumPy >= 1.24, using np.bool raises:

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

np.bool was an alias for Python's built-in bool.

Impact

  • Severity: High — hard crash at runtime on NumPy >= 1.24
  • Affects the correlation-based feature filtering in preprocessing/filters.py

Solution

# Before:
is_removed = np.zeros(X.shape[1], dtype=np.bool)

# After:
is_removed = np.zeros(X.shape[1], dtype=bool)

Python's built-in bool is the canonical replacement. np.bool_ can also be used if NumPy scalar type is explicitly required.

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions