Skip to content

Commit

Permalink
fix: don't let Awkward Array attempt to compare a big-endian array (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski authored Nov 7, 2024
1 parent 8ca7f15 commit a331467
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/uproot/writing/_cascadetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,9 @@ def extend(self, file, sink, data):
):
kk = self._counter_name(k)
vv = numpy.asarray(awkward.num(v, axis=1), dtype=">u4")
if kk in provided and not numpy.array_equal(vv, provided[kk]):
if kk in provided and not numpy.array_equal(
vv, awkward.to_numpy(provided[kk])
):
raise ValueError(
f"branch {kk!r} provided both as an explicit array and generated as a counter, and they disagree"
)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_1318_dont_compare_big_endian_in_awkward.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE

import os

import pytest
import awkward as ak

import uproot


def test(tmp_path):
filename = os.path.join(tmp_path, "whatever.root")

nMuon_pt = ak.Array([1, 2, 3])
Muon_pt = ak.Array([[1.1], [2.2, 3.3], [4.4, 5.5, 6.6]])

with uproot.recreate(filename) as file:
file["tree"] = {"nMuon_pt": nMuon_pt, "Muon_pt": Muon_pt}

0 comments on commit a331467

Please sign in to comment.