Skip to content

[Compatibility Issue] NumPy API removals: np.trapz + np.bool #11

Description

@xyf5432

Two NumPy APIs used in this repo have been removed in recent NumPy versions and will cause AttributeError at runtime.


1. np.trapz — removed in NumPy 2.4.0

Affected files:

  • ana/ckn.py:94, :111, :201
  • ana/trapz.py:21

Current:

# ana/ckn.py:94
cai2[i] = np.trapz(ir2[:i+1], en[:i+1])

# ana/ckn.py:111
s2i[i] = np.trapz(s2[:i+1], en[:i+1])

# ana/ckn.py:201
s2integral += np.trapz(fs2[:,1], fs2[:,0])

# ana/trapz.py:21
area_approx = np.trapz(y, x)

Fix: np.trapznp.trapezoid (same signature)

np.trapezoid(y, x)

trapz was deprecated in NumPy 2.0 (2023-08) and removed in NumPy 2.4.0 (2025-12). Refs: gpytorch#2695, NeuroKit#1155.

For NumPy < 2.0 backward compatibility:

try:
    from numpy import trapezoid as _trapz_impl
except ImportError:
    from numpy import trapz as _trapz_impl

2. np.bool — removed in NumPy 1.24

Affected files:

  • ana/seq.py:864
  • ana/cfh.py:297

Current:

# ana/seq.py:864
wk = np.zeros((len(aseq), 16), dtype=np.bool)

# ana/cfh.py:297
a = np.zeros(len(paths), dtype=np.bool)

Fix: np.boolbool (recommended) or np.bool_

dtype=bool

np.bool was deprecated in NumPy 1.20 and removed in NumPy 1.24 (2022-12). Refs: ultralytics#22930.


Summary

API NumPy removed Affected files Fix
np.trapz 2.4.0 ana/ckn.py ×3, ana/trapz.py ×1 np.trapezoid
np.bool 1.24 ana/seq.py:864, ana/cfh.py:297 bool

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions