Skip to content

Conversation

@mtsokol
Copy link
Contributor

@mtsokol mtsokol commented Aug 21, 2023

Hi @rgommers,

One of the functions that will be deprecated and removed in numPy 2.0 is np.trapz. It's the only integration function that still lives in NumPy instead of SciPy's scipy.integrate. In this PR I move implementation and tests directly to SciPy to then remove the original one from NumPy.

@mtsokol mtsokol requested a review from steppi as a code owner August 21, 2023 08:18
@andyfaff
Copy link
Contributor

@mtsokol we already have a integrate.trapezoid function available in scipy. I'd be reluctant to add this PR because it's likely to create confusion.

@mtsokol
Copy link
Contributor Author

mtsokol commented Aug 21, 2023

@mtsokol we already have a integrate.trapezoid function available in scipy. I'd be reluctant to add this PR because it's likely to create confusion.

@andyfaff To explain, scipy.integrate.trapezoid function is implemented as:

def trapezoid(y, x=None, dx=1.0, axis=-1):
"""..."""
    return np.trapz(y, x=x, dx=dx, axis=axis)

So it's only a wrapper for NumPy's function. This PR moves NumPy's implementation to Scipy, as we decided that trapz doesn't belong to NumPy (no SciPy API is being changed here).

@dschmitz89 dschmitz89 added scipy.integrate maintenance Items related to regular maintenance tasks labels Aug 21, 2023
@rgommers rgommers added this to the 1.12.0 milestone Aug 21, 2023
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @mtsokol. I verified that the implementation and tests match what's in numpy now.

@andyfaff with the added context from @mtsokol's answers, does this look okay to you?

@andyfaff
Copy link
Contributor

I think the cirrus ci fail is because hypothesis has only just been added to the ci config. A rebase on main would probably fix this, but I think it's mergeable as-is.

@andyfaff andyfaff merged commit 5bb7c04 into scipy:main Aug 22, 2023
@mtsokol mtsokol deleted the vendor-trapz-implementation branch August 22, 2023 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Items related to regular maintenance tasks scipy.integrate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants