Skip to content

Commit ed346ce

Browse files
committed
fix: don't let Awkward Array attempt to compare a big-endian array
1 parent de2f0d5 commit ed346ce

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/uproot/writing/_cascadetree.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,9 @@ def extend(self, file, sink, data):
585585
):
586586
kk = self._counter_name(k)
587587
vv = numpy.asarray(awkward.num(v, axis=1), dtype=">u4")
588-
if kk in provided and not numpy.array_equal(vv, provided[kk]):
588+
if kk in provided and not numpy.array_equal(
589+
vv, awkward.to_numpy(provided[kk])
590+
):
589591
raise ValueError(
590592
f"branch {kk!r} provided both as an explicit array and generated as a counter, and they disagree"
591593
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE
2+
3+
import os
4+
5+
import pytest
6+
import awkward as ak
7+
8+
import uproot
9+
10+
11+
def test(tmp_path):
12+
filename = os.path.join(tmp_path, "whatever.root")
13+
14+
nMuon_pt = ak.Array([1, 2, 3])
15+
Muon_pt = ak.Array([[1.1], [2.2, 3.3], [4.4, 5.5, 6.6]])
16+
17+
with uproot.recreate(filename) as file:
18+
file["tree"] = {"nMuon_pt": nMuon_pt, "Muon_pt": Muon_pt}

0 commit comments

Comments
 (0)