Histogramdd returns negative values after bins were not checked for monotonic increase
See original GitHub issueA call to np.histogram(2, bins=[1, 3, 1])
will raise a ValueError: bins must increase monotonically.
exception. However, arrays generated with a datatype of uint64
or np.uint64
will not be checked (correctly, at least) for monotonicity and will execute without a problem, generating a histogram with a negative value:
hist, edges = np.histogram(2, bins=np.array([1, 3, 1], dtype='uint64'))
# hist == np.array([1, -1])
The two problems here are obvious:
numpy
doesn’t check the monotonicity of the bins, or at least does so incorrectly.- A histogram with a negative value is returned.
I’m using numpy
version 1.12.1
with Python 3.6.1 on Windows 64 bit.
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (10 by maintainers)
Top Results From Across the Web
bins must increase monotonically - Stack Overflow
The histogram is of course not sorted and therefore the "bins must increase monotonically"-error is thrown.
Read more >numpy.histogram — NumPy v1.24 Manual
If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths....
Read more >sklearn.ensemble.HistGradientBoostingRegressor
Monotonic constraint to enforce on each feature are specified using the following integer values: 1: monotonic increase. 0: no constraint.
Read more >Metrics Types - Datadog Docs
This number of events can accumulate or decrease over time—it is not monotonically increasing. Note: A COUNT is different from the RATE metric...
Read more >numpy.lib.function_base — epygram 1.2.15 documentation
If the IQR is 0, this function returns 1 for the number of bins. ... Do not modify the original value of range...
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
Hey look, a float-integer overflow bug:
gives, on 1.13.3:
This one is definitely strictly increasing
#11023 has been merged, this no longer raises on master