Skip to content

Inconsistent values of bin_edges and bin_entries for SparselyBin #60

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
twalen opened this issue Aug 16, 2022 · 0 comments
Closed

Inconsistent values of bin_edges and bin_entries for SparselyBin #60

twalen opened this issue Aug 16, 2022 · 0 comments

Comments

@twalen
Copy link
Contributor

twalen commented Aug 16, 2022

In some cases SparselyBin returns inconsistent values of bin_edges / bin_entries if binWidth is float and low/high are given.

For example following code:

import numpy as np
from histogrammar.primitives.sparselybin import SparselyBin


values = np.array([0.114, 146.756, 302.333, 417.022, 720.324])
low, high = 314.0, 332.0

hist = SparselyBin(binWidth=10.1)
hist.fill.numpy(values)

edges = hist.bin_edges(low=low, high=high)
entries = hist.bin_entries(low=low, high=high)
print(f"edges={edges}")
print(f"entries={entries}")
assert len(edges) == len(entries) + 1

Gives assertion error:

edges=[313.1        319.83333333 326.56666667 333.3       ]
entries=[0. 0.]
Traceback (most recent call last):
  File "a.py", line 15, in <module>
    assert len(edges) == len(entries) + 1
AssertionError

This error is most likely related to the issue in popmon: ing-bank/popmon#244

twalen added a commit to twalen/histogrammar-python that referenced this issue Aug 16, 2022
twalen added a commit to twalen/histogrammar-python that referenced this issue Aug 18, 2022
twalen added a commit to twalen/histogrammar-python that referenced this issue Aug 18, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants