From 94e297941e0643a2b218703ed7e55c1fdbed3a75 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Wed, 15 Jan 2025 11:07:59 +0100 Subject: [PATCH] Revert use_times changes --- src/spikeinterface/core/baserecording.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/spikeinterface/core/baserecording.py b/src/spikeinterface/core/baserecording.py index fbdd1fa5ba..7ca527e255 100644 --- a/src/spikeinterface/core/baserecording.py +++ b/src/spikeinterface/core/baserecording.py @@ -59,7 +59,7 @@ def __repr__(self): if num_segments > 1: samples_per_segment = [self.get_num_samples(segment_index) for segment_index in range(num_segments)] memory_per_segment_bytes = (self.get_memory_size(segment_index) for segment_index in range(num_segments)) - durations = [self.get_duration(segment_index, use_times=False) for segment_index in range(num_segments)] + durations = [self.get_duration(segment_index) for segment_index in range(num_segments)] samples_per_segment_formated = [f"{samples:,}" for samples in samples_per_segment] durations_per_segment_formated = [convert_seconds_to_str(d) for d in durations] @@ -95,7 +95,7 @@ def _repr_header(self): dtype = self.get_dtype() total_samples = self.get_total_samples() - total_duration = self.get_total_duration(use_times=False) + total_duration = self.get_total_duration() total_memory_size = self.get_total_memory_size() sf_hz = self.get_sampling_frequency() @@ -216,7 +216,7 @@ def get_total_samples(self) -> int: return sum(samples_per_segment) - def get_duration(self, segment_index=None, use_times=True) -> float: + def get_duration(self, segment_index=None) -> float: """ Returns the duration in seconds. @@ -226,9 +226,6 @@ def get_duration(self, segment_index=None, use_times=True) -> float: The sample index to retrieve the duration for. For multi-segment objects, it is required, default: None With single segment recording returns the duration of the single segment - use_times : bool, default: True - If True, the duration is calculated using the time vector if available. - If False, the duration is calculated using the number of samples and the sampling frequency. Returns ------- @@ -237,7 +234,7 @@ def get_duration(self, segment_index=None, use_times=True) -> float: """ segment_index = self._check_segment_index(segment_index) - if self.has_time_vector(segment_index) and use_times: + if self.has_time_vector(segment_index): times = self.get_times(segment_index) segment_duration = times[-1] - times[0] + (1 / self.get_sampling_frequency()) else: @@ -246,24 +243,16 @@ def get_duration(self, segment_index=None, use_times=True) -> float: return segment_duration - def get_total_duration(self, use_times=True) -> float: + def get_total_duration(self) -> float: """ Returns the total duration in seconds - Parameters - ---------- - use_times : bool, default: True - If True, the duration is calculated using the time vector if available. - If False, the duration is calculated using the number of samples and the sampling frequency. - Returns ------- float The duration in seconds """ - duration = sum( - [self.get_duration(segment_index, use_times) for segment_index in range(self.get_num_segments())] - ) + duration = sum([self.get_duration(idx) for idx in range(self.get_num_segments())]) return duration def get_memory_size(self, segment_index=None) -> int: