fix: replace removed np.trapz and np.bool APIs - #12
Open
xyf5432 wants to merge 1 commit into
Open
Conversation
np.trapz was removed in numpy 2.4.0 and np.bool in numpy 1.24.0. Replace trapz calls with a compat shim preferring numpy.trapezoid and falling back to numpy.trapz on numpy<2, and np.bool with the builtin bool. Also update the docstring reference, the doc URL and the figure title in ana/trapz.py to the new API name.
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.
Fixes #11
Problem
Two removed numpy APIs are used in this repo:
np.trapz— removed in numpy 2.4.0 →AttributeError: module 'numpy' has no attribute 'trapz'on modern numpynp.bool— removed in numpy 1.24.0 →AttributeError: module 'numpy' has no attribute 'bool'on numpy >= 1.24Fix
np.trapz: add a compat shim inana/ckn.pyandana/trapz.pythat prefersnumpy.trapezoid(available since numpy 2.0, identical signature) and falls back tonumpy.trapzon numpy < 2.0, so the scripts keep working on every numpy version:np.bool: use the builtinbool, which numpy accepts as a dtype with identical behavior.ana/trapz.pyare updated to the new API name.Verification
np.trapezoid(y, x=None, dx=1.0, axis=-1)has an identical signature totrapzdtype=boolproduces identical boolean arraystrapzand computes the expected trapezoidal integral