scikit-hep / cabinetry

design and steer profile likelihood fits
https://cabinetry.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
28 stars 21 forks source link

fix: avoid mixing different versions of awkward in uproot5 tests #349

Closed alexander-held closed 2 years ago

alexander-held commented 2 years ago

The tests of the most recent versions of dependencies started failing for uproot5. The reason is that uproot5 uses the awkward v2 API, but the histogram creation code in cabinetry uses awkward directly as well (which currently results in v1). The two do not mix:

import awkward as ak
a = ak._v2.Array([1,2,3])
ak.to_numpy(a)

results in

TypeError: unrecognized array type: <Array [1, 2, 3] type='3 * int64'>

The solution is to call .to_numpy() on the relevant arrays instead, which will then use the v2 API in these tests. As uproot5 and awkward v2 should release at the same time, this probably would not have an impact on users, but this change should keep the tests working.

* fix test of upcoming versions of uproot5
codecov[bot] commented 2 years ago

Codecov Report

Merging #349 (fb61394) into master (0c75aad) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #349   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        23           
  Lines         1902      1901    -1     
  Branches       303       303           
=========================================
- Hits          1902      1901    -1     
Impacted Files Coverage Δ
src/cabinetry/contrib/histogram_creator.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0c75aad...fb61394. Read the comment docs.