Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/spikeinterface/core/baserecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def _extra_metadata_from_folder(self, folder):
for segment_index, rs in enumerate(self.segments):
time_file = folder / f"times_cached_seg{segment_index}.npy"
if time_file.is_file():
time_vector = np.load(time_file)
time_vector = np.load(time_file, mmap_mode="r")
rs.time_vector = time_vector

def _extra_metadata_to_folder(self, folder):
Expand Down
8 changes: 7 additions & 1 deletion src/spikeinterface/core/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,13 @@ def shift_times(self, shift: int | float, segment_index: int | None = None) -> N
rs = self.segments[segment_index]

if self.has_time_vector(segment_index=segment_index):
rs.time_vector += shift
if rs.time_vector.flags.writeable:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check if zarr.Array also implements this flag

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, it doesn't have this flag, so we should do:

```suggestion
                if isinstance(rs.time_vector, np.ndarray)  and rs.time_vector.flags.writeable:

# If the time_vector is writeable, shift in-place to avoid a copy.
rs.time_vector += shift
else:
# If the time_vector is a memmap from `np.load(..., mmap_mode='r')`,
# in-place modification would error, so we shift a writable copy.
rs.time_vector = rs.time_vector + shift
Comment thread
alejoe91 marked this conversation as resolved.
else:
new_start_time = 0 + shift if rs.t_start is None else rs.t_start + shift
rs.t_start = new_start_time
Expand Down
Loading