-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Awkward equivalent of some ROOT functions
- Loading branch information
1 parent
2612ef3
commit db9b24a
Showing
3 changed files
with
46 additions
and
4 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,41 @@ | ||
|
||
#maybe use num | ||
|
||
def root_length(array): | ||
import awkward as ak | ||
while array.layout.purelist_depth > 2: | ||
array = ak.flatten(array, axis=-1) | ||
return ak.count(array, axis=-1) | ||
|
||
|
||
def root_sum(array): | ||
import awkward as ak | ||
while array.layout.purelist_depth > 2: | ||
array = ak.flatten(array, axis=-1) | ||
return ak.sum(array, axis=-1) | ||
|
||
|
||
def root_min(array): | ||
import awkward as ak | ||
while array.layout.purelist_depth >= 2: | ||
array = ak.min(array, axis=-1) | ||
return ak.fill_none(array, 0) | ||
|
||
|
||
|
||
def root_max(array): | ||
import awkward as ak | ||
while array.layout.purelist_depth >= 2: | ||
array = ak.max(array, axis=-1) | ||
return ak.fill_none(array, 0) | ||
|
||
|
||
def root_min_if(array, condition): | ||
import awkward as ak | ||
array = array[condition != 0] | ||
return ak.fill_none(ak.min(array,axis=1),0) | ||
|
||
def root_max_if(array, condition): | ||
import awkward as ak | ||
array = array[condition != 0] | ||
return ak.fill_none(ak.max(array,axis=1),0) |
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