comparison trafficintelligence/moving.py @ 1306:4bc0651d91f9 default tip

bug corrected generating last velocity twice and saving it (not saved, duplicated at loading time
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 30 Mar 2026 15:31:34 -0400
parents f3574e43c238
children
comparison
equal deleted inserted replaced
1305:9c1870244adf 1306:4bc0651d91f9
1746 n = min(nInstantsIgnoredAtEnds, int(floor(self.length()/2.))) 1746 n = min(nInstantsIgnoredAtEnds, int(floor(self.length()/2.)))
1747 return speeds[n:-n] 1747 return speeds[n:-n]
1748 else: 1748 else:
1749 return speeds 1749 return speeds
1750 1750
1751 def computeVelocities(self, halfWidth = None): 1751 def computeVelocities(self, halfWidth = None, duplicateLastVelocity = True):
1752 '''compute velocities, smoothed if halfwidth is not None ''' 1752 '''compute velocities, smoothed if halfwidth is not None '''
1753 if halfWidth is None: 1753 if halfWidth is None:
1754 self.velocities = self.getPositions().differentiate(True) 1754 self.velocities = self.getPositions().differentiate(True)
1755 else: 1755 else:
1756 self.velocities = self.getPositions().differentiate().filterMovingWindow(halfWidth) 1756 self.velocities = self.getPositions().differentiate().filterMovingWindow(halfWidth)
1757 self.velocities.addPosition(self.velocities[-1]) 1757 if duplicateLastVelocity:
1758 self.velocities.addPosition(self.velocities[-1])
1758 1759
1759 def smoothPositions(self, halfWidth, replace = False): 1760 def smoothPositions(self, halfWidth, replace = False):
1760 'Returns the smoothed positions (or replaces them)' 1761 'Returns the smoothed positions (or replaces them)'
1761 smoothed = self.getPositions().filterMovingWindow(halfWidth) 1762 smoothed = self.getPositions().filterMovingWindow(halfWidth)
1762 if replace: 1763 if replace: