Skip to content

np.trapz is deprecated. Updating to np.trapezoid#45

Merged
bd-j merged 2 commits intobd-j:mainfrom
sbruto:trapz_deprecation
May 29, 2025
Merged

np.trapz is deprecated. Updating to np.trapezoid#45
bd-j merged 2 commits intobd-j:mainfrom
sbruto:trapz_deprecation

Conversation

@sbruto
Copy link
Copy Markdown
Contributor

@sbruto sbruto commented May 21, 2025

Changes are in observate.py and smoothing.py

Changes are in observate.py and smoothing.py
@bd-j
Copy link
Copy Markdown
Owner

bd-j commented May 29, 2025

Thanks @sbruto for this PR!

According to the tests this breaks in numpy < 2.0 (as used in the python3.9 test). While I'd be fine requiring python >=3.10 I think there are still some cases where numpy < 2.0 is useful in some environments, even with more recent python, so I'm hesitant to merge this as-is.

@bd-j
Copy link
Copy Markdown
Owner

bd-j commented May 29, 2025

Perhaps something like

try:
    from numpy import trapezoid
except(ImportError):
    from numpy import trapz as trapezoid

And then use trapezoid below.

@bd-j bd-j mentioned this pull request May 29, 2025
@bd-j
Copy link
Copy Markdown
Owner

bd-j commented May 29, 2025

Great, thanks! Merging.

@bd-j bd-j merged commit bd9b892 into bd-j:main May 29, 2025
4 checks passed
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.

2 participants