Skip to content

Commit

Permalink
Fixes split for uint16 case.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanaif committed Oct 17, 2023
1 parent d7e908a commit 80eded4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/uproot/models/RNTuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,22 @@ def read_pagedesc(self, destination, desc, dtype_str, dtype, nbits, split):

if split:
if nbits == 16:
res = numpy.empty(len(content), numpy.uint8)
res = numpy.empty(len(content), numpy.uint16)
content = content.view(numpy.uint8)
res[::2] = content[0 : len(res) // 2]
res[1::2] = content[len(res) // 2 : len(res)]

elif nbits == 32:
res = numpy.empty(len(content), numpy.uint8)
res = numpy.empty(len(content), numpy.uint32)
content = content.view(numpy.uint8)
res[::4] = content[0 : len(res) // 4]
res[1::4] = content[len(res) // 4 : len(res) // 2]
res[2::4] = content[len(res) // 2 : 3 * len(res) // 4]
res[3::4] = content[3 * len(res) // 4 : len(res)]

elif nbits == 64:
res = numpy.empty(len(content) * 8, numpy.uint8)
content = content.view(numpy.uint8)
res[::8] = content[0 : len(res) // 8]
res[1::8] = content[len(res) // 8 : 2 * len(res) // 8]
res[2::8] = content[2 * len(res) // 8 : 3 * len(res) // 8]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_0962-RNTuple-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_new_support_RNTuple_split_int32_reading():
df = obj.arrays()
assert len(df) == 5e4
assert len(df.one_integers) == 5e4
assert np.all(df.one_integers == np.arange(5e4)[::-1][:-1])
assert np.all(df.one_integers == np.arange(5e4 + 1)[::-1][:-1])


def test_new_support_RNTuple_bit_bool_reading():
Expand Down

0 comments on commit 80eded4

Please sign in to comment.