-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Made parquet merge, works but needs max_files_open? * added to test * Fixed for nested arrays, added test * globbing
- Loading branch information
Showing
3 changed files
with
335 additions
and
0 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,112 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
import awkward as ak | ||
import pytest | ||
|
||
from hepconvert import merge, root_to_parquet | ||
|
||
skhep_testdata = pytest.importorskip("skhep_testdata") | ||
|
||
|
||
def simple_test(tmp_path): | ||
arr1 = ak.Array( | ||
{ | ||
"a": [ | ||
1, | ||
2, | ||
], | ||
"b": [ | ||
1, | ||
2, | ||
], | ||
"c": [ | ||
1, | ||
2, | ||
], | ||
} | ||
) | ||
ak.to_parquet(arr1, Path(tmp_path / "arr1.parquet")) | ||
arr2 = ak.Array( | ||
{ | ||
"a": [7, 8, 9], | ||
"b": [ | ||
3, | ||
4, | ||
5, | ||
], | ||
} | ||
) | ||
ak.to_parquet(arr2, Path(tmp_path / "arr2.parquet")) | ||
arr3 = ak.Array( | ||
{ | ||
"a": [10, 11, 12, 13, 14], | ||
"c": [3, 4, 5, 6, 7], | ||
"d": [1, 2, 3, 4, 5], | ||
} | ||
) | ||
ak.to_parquet(arr3, Path(tmp_path / "arr3.parquet")) | ||
|
||
merge.merge_parquet( | ||
Path(tmp_path / "new.parquet"), | ||
[ | ||
Path(tmp_path / "arr1.parquet"), | ||
Path(tmp_path / "arr2.parquet"), | ||
Path(tmp_path / "arr3.parquet"), | ||
], | ||
force=True, | ||
) | ||
array = ak.from_parquet(Path(tmp_path / "new.parquet")) | ||
assert ak.all(array["a"] == [1, 2, 7, 8, 9, 10, 11, 12, 13, 14]) | ||
assert ak.all( | ||
array["b"] | ||
== [ | ||
1, | ||
2, | ||
3, | ||
4, | ||
5, | ||
None, | ||
None, | ||
None, | ||
None, | ||
None, | ||
] | ||
) | ||
assert ak.all(array["c"] == [1, 2, None, None, None, 3, 4, 5, 6, 7]) | ||
assert ak.all( | ||
array["d"] | ||
== [ | ||
None, | ||
None, | ||
None, | ||
None, | ||
None, | ||
1, | ||
2, | ||
3, | ||
4, | ||
5, | ||
] | ||
) | ||
|
||
|
||
def HZZ_test(tmp_path): | ||
merge.merge_parquet( | ||
Path(tmp_path / "/merged_hzz.parquet"), | ||
[ | ||
Path(tmp_path / "/uproot-HZZ.parquet"), | ||
Path(tmp_path / "/uproot-HZZ.parquet"), | ||
], | ||
force=True, | ||
) | ||
new_arrays = ak.from_parquet(Path(tmp_path / "/new.parquet")) | ||
root_to_parquet( | ||
Path(tmp_path / "/merged_hzz.root"), | ||
Path(tmp_path / "/merged_hzz.parquet"), | ||
force=True, | ||
) | ||
test = ak.from_parquet(Path(tmp_path / "/merged_hzz.parquet")) | ||
for key in new_arrays.fields: | ||
assert ak.all(new_arrays[key] == test[key]) |
File renamed without changes.