Skip to content

Commit

Permalink
Bug fix: evt.modules.spm.cast_trigger where Awkward arrays not repl…
Browse files Browse the repository at this point in the history
…acing `nan`s (#559)

* fixed bug in cast_triger where awk arrays not replacing nans
  • Loading branch information
ggmarshall authored Feb 19, 2024
1 parent e6cf95c commit a6d5aac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/pygama/evt/modules/spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ def cast_trigger(
ak.min(ak.fill_none(trgr.view_as("ak"), tdefault), axis=-1), tdefault
)

elif isinstance(trgr, ak.Array):
elif isinstance(trgr, (ak.Array, ak.highlevel.Array)):
if trgr.ndim == 1:
return ak.fill_none(trgr, tdefault)
return ak.fill_none(ak.nan_to_none(trgr), tdefault)
elif trgr.ndim == 2:
return ak.fill_none(ak.min(ak.fill_none(trgr, tdefault), axis=-1), tdefault)
return ak.fill_none(
ak.min(ak.fill_none(ak.nan_to_none(trgr), tdefault), axis=-1), tdefault
)
else:
raise ValueError(f"Too many dimensions: {trgr.ndim}")
elif isinstance(trgr, (float, int)) and isinstance(length, int):
Expand Down
7 changes: 1 addition & 6 deletions src/pygama/flow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@ def fill_col_dict(
(table_length, len(tier_table[col].nda[0])),
dtype=tier_table[col].dtype,
)
try:
col_dict[col][tcm_idx] = tier_table[col].nda
except BaseException:
raise ValueError(
f"self.aoesa_to_vov is False but {col} is a jagged array"
)
col_dict[col][tcm_idx] = tier_table[col].nda
elif isinstance(tier_table[col], VectorOfVectors):
# Allocate memory for column for all channels
if col not in col_dict.keys():
Expand Down

0 comments on commit a6d5aac

Please sign in to comment.