Skip to content

Histogramdd returns negative values after bins were not checked for monotonic increase #9222

@HagaiHargil

Description

@HagaiHargil

A 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:

  1. numpy doesn't check the monotonicity of the bins, or at least does so incorrectly.
  2. 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions