Skip to content

Fix 'numpy' has no attribute 'trapz' issue#287

Merged
FanwangM merged 2 commits intomainfrom
fix_numpy
Feb 3, 2026
Merged

Fix 'numpy' has no attribute 'trapz' issue#287
FanwangM merged 2 commits intomainfrom
fix_numpy

Conversation

@FanwangM
Copy link
Collaborator

@FanwangM FanwangM commented Feb 3, 2026

The numpy.trapz was deprecated since NumPy 2.0 (2023-08-18). Use numpy.trapezoid as replacement.

https://github.com/numpy/numpy/blob/f6440be7b8eec4a6481832f15f6730d984d78ef0/doc/source/release/2.4.0-notes.rst#L191

Copilot AI review requested due to automatic review settings February 3, 2026 02:30
@FanwangM FanwangM merged commit a536369 into main Feb 3, 2026
20 checks passed
Copy link
Contributor

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 addresses the deprecation of numpy.trapz in NumPy 2.0 by migrating to the replacement function numpy.trapezoid. The PR updates both the code implementation and the minimum NumPy version requirement in the dependencies.

Changes:

  • Replaced deprecated np.trapz with np.trapezoid in the WDUD diversity calculation
  • Updated minimum NumPy version requirement from >=1.21.2 to >=2.0.0
  • Updated code comment to reflect the use of np.trapezoid

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
selector/measures/diversity.py Replaced deprecated np.trapz with np.trapezoid in the wdud function and updated associated comment
requirements.txt Updated minimum NumPy version from >=1.21.2 to >=2.0.0 to ensure compatibility with the new API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant