-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from DUNE/feature_evt_builder_updates
Event builder updates prior to FSD reflow
- Loading branch information
Showing
4 changed files
with
166 additions
and
55 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
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,16 @@ | ||
import numpy as np | ||
|
||
|
||
def fill_with_last(arr: np.ndarray) -> np.ndarray: | ||
''' | ||
Given an array ARR, copy it and replace all zeros with the last | ||
nonzero value. E.g., | ||
[3, 0, 0, 5, 0, 8, 0, 0, 0] => [3, 3, 3, 5, 5, 8, 8, 8, 8]. | ||
TODO: Replace with a faster implementation. (This one is based on | ||
the code that calculates unix_ts in raw_event_generator.py.) | ||
''' | ||
groups = np.split(arr, np.argwhere(arr).ravel()) | ||
# SLOW: | ||
groups = [np.full(len(group), group[0]) | ||
for group in groups if len(group)] | ||
return np.concatenate(groups, axis=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