Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gviejo committed May 23, 2024
1 parent 730aa31 commit 53670e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pynapple/core/_core_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ def _dropna(time_array, data_array, starts, ends, update_time_support, ndim):
ends,
)
elif np.any(index_nan):
tokeep = np.where(~index_nan)[0]
if update_time_support:
starts, ends = jitremove_nan(time_array, index_nan)

to_fix = starts == ends
if np.any(to_fix):
ends[to_fix] += 1e-6 # adding 1 millisecond in case of a single point

return (time_array[~index_nan], data_array[~index_nan], starts, ends)
return (time_array[tokeep], data_array[tokeep], starts, ends)
else:
return (time_array[~index_nan], data_array[~index_nan], starts, ends)
return (time_array[tokeep], data_array[tokeep], starts, ends)
else:
return (time_array, data_array, starts, ends)

Expand Down
1 change: 1 addition & 0 deletions pynapple/core/_jitted_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ def _jitbin_array(countin, time_array, data_array, starts, ends, bin_size):
break

lbound += bin_size
lbound = np.round(lbound, 9)
b += 1
t = maxt
k += 1
Expand Down
10 changes: 10 additions & 0 deletions pynapple/core/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,10 @@ def __init__(
The time units in which times are specified ('us', 'ms', 's' [default]).
time_support : IntervalSet, optional
The time support of the TsdFrame object
load_array : bool, optional
Whether the data should be converted to a numpy (or jax) array. Useful when passing a memory map object like zarr.
Default is True. Does not apply if `d` is already a numpy array.
"""
super().__init__(t, d, time_units, time_support, load_array)

Expand Down Expand Up @@ -868,6 +872,9 @@ def __init__(
The time support of the TsdFrame object
columns : iterables
Column names
load_array : bool, optional
Whether the data should be converted to a numpy (or jax) array. Useful when passing a memory map object like zarr.
Default is True. Does not apply if `d` is already a numpy array.
"""

c = columns
Expand Down Expand Up @@ -1144,6 +1151,9 @@ def __init__(
The time units in which times are specified ('us', 'ms', 's' [default])
time_support : IntervalSet, optional
The time support of the tsd object
load_array : bool, optional
Whether the data should be converted to a numpy (or jax) array. Useful when passing a memory map object like zarr.
Default is True. Does not apply if `d` is already a numpy array.
"""
if isinstance(t, pd.Series):
d = t.values
Expand Down

0 comments on commit 53670e8

Please sign in to comment.