Skip to content

napari_matplotlib.histogram._get_bins returns different bins depending on type of data passed to it #249

New issue

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

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

Already on GitHub? Sign in to your account

Closed
p-j-smith opened this issue Jan 15, 2024 · 0 comments · Fixed by #250

Comments

@p-j-smith
Copy link
Contributor

p-j-smith commented Jan 15, 2024

napari_matplotlib.histogram._get_bins returns fewer bins if the data passed to it are float compared to if they are int.

To reproduce:

import numpy as np
from napari_matplotlib.histogram import _get_bins

data = np.arange(0, 101, dtype=int)
print(_get_bins(data).size)
print(_get_bins(data.astype(float)).size)

which prints:

101
100

To fix, perhaps 100 bins (101 bin edges) should be created with np.linspace for float data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant