-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for more RNTuple types (#1223)
* Add support for std::atomic<T> * Add support for std::bitset * Don't prune RNTuple records * Fixed bug reading page description * Attempt at supporting invalid variants * Added tests * Treat invalid variants as None * Specify dtype for np.arange
- Loading branch information
Showing
2 changed files
with
130 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE | ||
|
||
import pytest | ||
import skhep_testdata | ||
|
||
import uproot | ||
|
||
|
||
def test_atomic(): | ||
filename = skhep_testdata.data_path("test_ntuple_atomic_bitset.root") | ||
with uproot.open(filename) as f: | ||
obj = f["ntuple"] | ||
|
||
a = obj.arrays("atomic_int") | ||
|
||
assert a.atomic_int.tolist() == [1, 2, 3] | ||
|
||
|
||
def test_bitset(): | ||
filename = skhep_testdata.data_path("test_ntuple_atomic_bitset.root") | ||
with uproot.open(filename) as f: | ||
obj = f["ntuple"] | ||
|
||
a = obj.arrays("bitset") | ||
|
||
assert len(a.bitset) == 3 | ||
assert len(a.bitset[0]) == 42 | ||
assert a.bitset[0].tolist()[:6] == [0, 1, 0, 1, 0, 1] | ||
assert all(a.bitset[0][6:] == 0) | ||
assert a.bitset[1].tolist()[:16] == [ | ||
0, | ||
1, | ||
0, | ||
1, | ||
0, | ||
1, | ||
0, | ||
1, | ||
0, | ||
1, | ||
0, | ||
1, | ||
0, | ||
1, | ||
0, | ||
1, | ||
] | ||
assert all(a.bitset[1][16:] == 0) | ||
assert a.bitset[2].tolist()[:16] == [ | ||
0, | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
0, | ||
1, | ||
] | ||
assert all(a.bitset[2][16:] == 0) | ||
|
||
|
||
def test_empty_struct(): | ||
filename = skhep_testdata.data_path("test_ntuple_emptystruct_invalidvar.root") | ||
with uproot.open(filename) as f: | ||
obj = f["ntuple"] | ||
|
||
a = obj.arrays("empty_struct") | ||
|
||
assert a.empty_struct.tolist() == [{}, {}, {}] | ||
|
||
|
||
def test_invalid_variant(): | ||
filename = skhep_testdata.data_path("test_ntuple_emptystruct_invalidvar.root") | ||
with uproot.open(filename) as f: | ||
obj = f["ntuple"] | ||
|
||
a = obj.arrays("variant") | ||
|
||
assert a.variant.tolist() == [1, 1, None] |