Skip to content

Commit

Permalink
Move set_nan_defaults from straxen to strax (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
dachengx authored Dec 16, 2024
1 parent 574661b commit 956031e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions strax/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ def accumulate_numba_result(*args, **kwargs):
return _growing_result


@export
def set_nan_defaults(buffer):
"""When constructing the dtype, take extra care to set values to np.Nan / -1 (for ints) as 0
might have a meaning."""
for field in buffer.dtype.names:
if np.issubdtype(buffer.dtype[field], np.integer):
buffer[field][:] = -1
else:
buffer[field][:] = np.nan


@export
def unpack_dtype(dtype):
"""Return list of tuples needed to construct the dtype.
Expand Down

0 comments on commit 956031e

Please sign in to comment.