Skip to content

Commit

Permalink
Revert use_times changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Jan 15, 2025
1 parent ca276f8 commit 94e2979
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/spikeinterface/core/baserecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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.
Expand All @@ -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
-------
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 94e2979

Please sign in to comment.