Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/moving.py @ 1287:76f5693b530c
updated tests for numpy 2
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Sat, 20 Jul 2024 20:35:21 -0400 |
| parents | 77a310e29233 |
| children | 86122f5fe500 |
comparison
equal
deleted
inserted
replaced
| 1284:8e30c9a6ac6f | 1287:76f5693b530c |
|---|---|
| 2 '''Libraries for moving objects, trajectories...''' | 2 '''Libraries for moving objects, trajectories...''' |
| 3 | 3 |
| 4 import copy | 4 import copy |
| 5 from math import sqrt, atan2, cos, sin, inf | 5 from math import sqrt, atan2, cos, sin, inf |
| 6 | 6 |
| 7 from numpy import median, mean, array, arange, zeros, ones, hypot, NaN, std, floor, ceil, float32, argwhere, flatnonzero, minimum, issubdtype, integer as npinteger, percentile, quantile, full | 7 from numpy import median, mean, array, arange, zeros, ones, hypot, nan, std, floor, ceil, float32, argwhere, flatnonzero, minimum, issubdtype, integer as npinteger, percentile, quantile, full |
| 8 from matplotlib.pyplot import plot, text, arrow | 8 from matplotlib.pyplot import plot, text, arrow |
| 9 from scipy.spatial.distance import cdist | 9 from scipy.spatial.distance import cdist |
| 10 from scipy.signal import savgol_filter | 10 from scipy.signal import savgol_filter |
| 11 | 11 |
| 12 try: | 12 try: |
| 1665 for t, p in zip(self.getTimeInterval(), self.curvilinearPositions): | 1665 for t, p in zip(self.getTimeInterval(), self.curvilinearPositions): |
| 1666 if p[2] == lane: | 1666 if p[2] == lane: |
| 1667 instants.append(t) | 1667 instants.append(t) |
| 1668 coords.append(p[0]) | 1668 coords.append(p[0]) |
| 1669 else: | 1669 else: |
| 1670 instants.append(NaN) | 1670 instants.append(nan) |
| 1671 coords.append(NaN) | 1671 coords.append(nan) |
| 1672 plot(instants, coords, options, **kwargs) | 1672 plot(instants, coords, options, **kwargs) |
| 1673 if withOrigin and len(instants)>0: | 1673 if withOrigin and len(instants)>0: |
| 1674 plot([instants[0]], [coords[0]], 'ro', **kwargs) | 1674 plot([instants[0]], [coords[0]], 'ro', **kwargs) |
| 1675 else: | 1675 else: |
| 1676 print('Object {} has no curvilinear positions'.format(self.getNum())) | 1676 print('Object {} has no curvilinear positions'.format(self.getNum())) |
