.ptp() can return negative numbers
See original GitHub issueThis is worked around in https://github.com/numpy/numpy/pull/14381 and mentioned in https://github.com/numpy/numpy/issues/3292#issuecomment-543626173 but still seems to behave like this. I don’t see why anyone would ever want it to return a negative number, so I think it should be considered a bug.
Reproducing code example:
import numpy as np
np.array([32767, -1], np.int16).ptp()
It returns np.int16(-32768)
, but it should logically return np.uint16(32768)
or int(32768)
.
Numpy/Python version information:
1.17.4 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
numpy.ptp — NumPy v1.24 Manual
ptp preserves the data type of the array. ... This example shows that a negative value can be returned when the input is...
Read more >Python 3.6.1 - Numpy.power returns negative values for cube ...
1 Answer 1 ... This happens because the cube of 1963 is greater than the maximum number (2,147,483,647) which can be stored in...
Read more >NumPy ptp() function - Studytonight
This function is used to return a range of values along an axis. The range can be calculated using range= maximum_value - minimum_value....
Read more >[SciPy-user] negative values in diagonal of covariance matrix
Hi all, I'm a moderately new user of scipy, trying to make some curve-fitting with it. I wanted to use cov matrix output...
Read more >Precision Time Protocol Software Configuration Guide for IE ...
Adding PTP to a network can compensate for these latency and delay ... Port 2 returns and generates timestamp t3 for a Pdelay_Resp...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
See https://github.com/numpy/numpy/pull/16240
I’d rather not see that, too trivial/niche for numpy at this point.