Skip to content

Commit

Permalink
fix segment length rounding error
Browse files Browse the repository at this point in the history
  • Loading branch information
tmchartrand authored and sgratiy committed Jan 5, 2021
1 parent 8f231d1 commit 79bd4af
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ipfx/x_to_nwb/hr_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ def calculateNumberOfPoints(self, duration):
"""
Return the number of points of this segment.
"""
return math.trunc(duration / self.sampleInterval)
num_points = duration / self.sampleInterval
num_points_int = int(np.round(num_points))
if not math.isclose(num_points, num_points_int):
raise ValueError(f"Segment duration {duration} is not divisible by sample interval {self.sampleInterval}")
return num_points_int

def getAmplitude(self, channelRec, segmentRec):
"""
Expand Down

0 comments on commit 79bd4af

Please sign in to comment.