Skip to content

Conversation

andyfaff
Copy link
Contributor

@andyfaff andyfaff commented Aug 16, 2023

This is related to #18781.
When performing integrate.simpson(np.array([1,2,3.]), x=np.array([1, 2, 3.])) in a script I was experiencing DeprecationWarnings of the form reported #18781. The warning is also emitted with length 4 arrays.
These were not visible in the scipy test suite, probably because this line meant that all DeprecationWarnings, including the numpy warnings, weren't visible.

The numpy warnings were caused by the lines:

h0 = np.float64(h[sl0])
h1 = np.float64(h[sl1])

If h[sl0]) has length 1, then the np.float64 call raises the warning (similar argument for h1). The warning doesn't occur if the length is greater than 1. The solution is to use np.ndarray.astype. h[sl0] will always be an array, so casting to float should always work. The test suite already examines a case where the integrate set has length 4.

Copy link
Contributor

@mdhaber mdhaber left a comment

Choose a reason for hiding this comment

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

Thanks, @andyfaff.

@mdhaber mdhaber merged commit 06fe829 into scipy:main Aug 16, 2023
@j-bowhay j-bowhay added this to the 1.12.0 milestone Aug 17, 2023
@andyfaff andyfaff added the backport-candidate This fix should be ported by a maintainer to previous SciPy versions. label Sep 5, 2023
@tylerjereddy tylerjereddy modified the milestones: 1.12.0, 1.11.3 Sep 21, 2023
@tylerjereddy tylerjereddy removed the backport-candidate This fix should be ported by a maintainer to previous SciPy versions. label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants