Skip to content
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

Plotting fails on branches all filled with the same value #38

Open
davehadley opened this issue Mar 18, 2022 · 1 comment
Open

Plotting fails on branches all filled with the same value #38

davehadley opened this issue Mar 18, 2022 · 1 comment

Comments

@davehadley
Copy link

On latest pypi version uproot-browser 0.4.0 when plotting branches all filled with the same value I see the error message:

╭────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                               │
│ /storage/epp2/phskaj/t2k/ncfgd/2022-03-01/ncfgd/env/ncfgd/lib/python3.8/site-packages/uproot_browser/plot_view.py:55 in __rich_console__                                                                                      │
│                                                                                                                                                                                                                               │
│    54 │   │   try:                                                                                                                                                                                                            │
│ ❱  55 │   │   │   canvas = make_plot(self.item, width, height)                                                                                                                                                                │
│    56 │   │   │   yield rich.text.Text.from_ansi(canvas)                                                                                                                                                                      │
│ /storage/epp2/phskaj/t2k/ncfgd/2022-03-01/ncfgd/env/ncfgd/lib/python3.8/site-packages/uproot_browser/plot_view.py:40 in make_plot                                                                                             │
│                                                                                                                                                                                                                               │
│    39 │   plt.plotsize(*size)                                                                                                                                                                                                 │
│ ❱  40 │   uproot_browser.plot.plot(item)                                                                                                                                                                                      │
│    41 │   return plt.build()                                                                                                                                                                                                  │
│                                                                                                                                                                                                                               │
│ /storage/epp2/phskaj/t2k/ncfgd/2022-03-01/ncfgd/env/ncfgd/lib/python3.8/functools.py:875 in wrapper                                                                                                                           │
│                                                                                                                                                                                                                               │
│   874 │   │                                                                                                                                                                                                                   │
│ ❱ 875 │   │   return dispatch(args[0].__class__)(*args, **kw)                                                                                                                                                                 │
│   876                                                                                                                                                                                                                         │
│                                                                                                                                                                                                                               │
│ /storage/epp2/phskaj/t2k/ncfgd/2022-03-01/ncfgd/env/ncfgd/lib/python3.8/site-packages/uproot_browser/plot.py:58 in plot_branch                                                                                                │
│                                                                                                                                                                                                                               │
│   57 │   finite = values[np.isfinite(values)]                                                                                                                                                                                 │
│ ❱ 58 │   histogram: hist.Hist = hist.numpy.histogram(finite, bins=100, histogram=hist.Hist)                                                                                                                                   │
│   59 │   plt.bar(histogram.axes[0].centers, histogram.values().astype(float))                                                                                                                                                 │
│                                                                                                                                                                                                                               │
│ /storage/epp2/phskaj/t2k/ncfgd/2022-03-01/ncfgd/env/ncfgd/lib/python3.8/site-packages/boost_histogram/numpy.py:166 in histogram                                                                                               │
│                                                                                                                                                                                                                               │
│   165 │                                                                                                                                                                                                                       │
│ ❱ 166 │   result = histogramdd(                                                                                                                                                                                               │
│   167 │   │   (a,),                                                                                                                                                                                                           │
│                                                                                                                                                                                                                               │
│ /storage/epp2/phskaj/t2k/ncfgd/2022-03-01/ncfgd/env/ncfgd/lib/python3.8/site-packages/boost_histogram/numpy.py:78 in histogramdd                                                                                              │
│                                                                                                                                                                                                                               │
│    77 │   │   │   │   r = (np.amin(a[n]), np.amax(a[n]))                                                                                                                                                                      │
│ ❱  78 │   │   │   cpp_ax = _core.axis.regular_numpy(b, r[0], r[1])                                                                                                                                                            │
│    79 │   │   │   new_ax = _cast(None, cpp_ax, _axis.Axis)                                                                                                                                                                    │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: range of axis is zero

so I guess that some special behaviour is needed for the case where the min and max of the value being plotted are the same.

BTW this looks like a great project, thank you. :)

@henryiii
Copy link
Member

scikit-hep/boost-histogram#721

Though a bh release might not be rushed out, so might patch it here too for now.

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

No branches or pull requests

2 participants