At the moment there does not seem to be support for NumPy ufuncs for hist
histograms created from uproot
's .to_hist()
API.
$ git clone git@gist.github.com:ab6ac8677aad2e04738111d0af3e0549.git hist-issue
$ cd hist-issue
$ pyenv virtualenv 3.8.7 hist-issue
$ pyenv activate hist-issue
(hist-issue) $ pip install --upgrade --quiet pip setuptools wheel
(hist-issue) $ cat requirements.txt
hist[plot]==2.2.0
uproot~=4.0.6
uproot3~=3.14.4
jupyter~=1.0
jupyterlab~=2.2
(hist-issue) $ pip install -r requirements.txt
(hist-issue) $ python minimal-failing.py
hists in file: ['mass;1']
Traceback (most recent call last):
File "minimal-failing.py", line 100, in <module>
main()
File "minimal-failing.py", line 96, in main
minimal_failing(root_file)
File "minimal-failing.py", line 74, in minimal_failing
sqrt_values = np.sqrt(hist_mass)
TypeError: ufunc 'sqrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
(hist-issue) $ python minimal-failing.py pass
np.sqrt gives: [0. 0. 0. 0. 0. 0.36136437
1.36677301 2.24499357 3.3028363 4.01532338 4.46574546 4.50899645
4.54050631 4.45316398 4.04590633 3.8036544 3.50747509 3.26808198
2.91475639 2.61148735 2.36931914 2.15342051 1.73440724 1.6316221
1.40370282 1.23654795 1.06892428 1.0623001 0.95068096 0.73183709
0.50208207 0.58183567 0.53861281 0.39997453 0.35529868 0.28219637
0.20478919 0.18039576 0.19334187 0.07509284 0. 0.
0.07867583 0. 0. 0. 0.10174972 0.
0. 0. ]
@henryiii has pointed out this isn't really using the proper API and I should be using
Which is already what I'm doing in the
minimal_passing
example, so that's seem fair. 👍