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 t-b committed Dec 6, 2020
1 parent 6df48ad commit fd49e1b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/x_to_nwb/hr_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,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 fd49e1b

Please sign in to comment.