comparison trafficintelligence/tests/moving.txt @ 1287:76f5693b530c

updated tests for numpy 2
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 20 Jul 2024 20:35:21 -0400
parents fe35473acee3
children f3574e43c238
comparison
equal deleted inserted replaced
1284:8e30c9a6ac6f 1287:76f5693b530c
185 185
186 186
187 >>> from utils import LCSS 187 >>> from utils import LCSS
188 >>> lcss = LCSS(lambda x,y: Point.distanceNorm2(x,y) <= 0.1) 188 >>> lcss = LCSS(lambda x,y: Point.distanceNorm2(x,y) <= 0.1)
189 >>> Trajectory.lcss(t1, t1, lcss) 189 >>> Trajectory.lcss(t1, t1, lcss)
190 3 190 np.int64(3)
191 >>> lcss = LCSS(lambda p1, p2: (p1-p2).normMax() <= 0.1) 191 >>> lcss = LCSS(lambda p1, p2: (p1-p2).normMax() <= 0.1)
192 >>> Trajectory.lcss(t1, t1, lcss) 192 >>> Trajectory.lcss(t1, t1, lcss)
193 3 193 np.int64(3)
194 194
195 >>> p1=Point(0,0) 195 >>> p1=Point(0,0)
196 >>> p2=Point(1,0) 196 >>> p2=Point(1,0)
197 >>> v1 = Point(0.1,0.1) 197 >>> v1 = Point(0.1,0.1)
198 >>> v2 = Point(-0.1, 0.1) 198 >>> v2 = Point(-0.1, 0.1)
251 >>> o1.setNObjects(1.1) 251 >>> o1.setNObjects(1.1)
252 >>> o1.setNObjects(0.5) 252 >>> o1.setNObjects(0.5)
253 Number of objects represented by object 1 must be greater or equal to 1 (0.5) 253 Number of objects represented by object 1 must be greater or equal to 1 (0.5)
254 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(0,10)) 254 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(0,10))
255 >>> MovingObject.computePET(o1, o2, 0.1) 255 >>> MovingObject.computePET(o1, o2, 0.1)
256 (0.0, 5, 5) 256 (np.float64(0.0), np.int64(5), np.int64(5))
257 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(5,15)) 257 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(5,15))
258 >>> MovingObject.computePET(o1, o2, 0.1) 258 >>> MovingObject.computePET(o1, o2, 0.1)
259 (5.0, 5, 10) 259 (np.float64(5.0), np.int64(5), np.int64(10))
260 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(15,30)) 260 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(15,30))
261 >>> MovingObject.computePET(o1, o2, 0.1) 261 >>> MovingObject.computePET(o1, o2, 0.1)
262 (15.0, 5, 20) 262 (np.float64(15.0), np.int64(5), np.int64(20))
263 263
264 >>> o1 = MovingObject(1, TimeInterval(0,10), features=[MovingObject.generate(1, Point(0., 3.), Point(1., 0.), TimeInterval(0,10)), MovingObject.generate(2, Point(2., 3.), Point(1., 0.), TimeInterval(0,10)), MovingObject.generate(3, Point(2., 4.), Point(1., 0.), TimeInterval(0,10)), MovingObject.generate(4, Point(0., 4.), Point(1., 0.), TimeInterval(0,10))]) 264 >>> o1 = MovingObject(1, TimeInterval(0,10), features=[MovingObject.generate(1, Point(0., 3.), Point(1., 0.), TimeInterval(0,10)), MovingObject.generate(2, Point(2., 3.), Point(1., 0.), TimeInterval(0,10)), MovingObject.generate(3, Point(2., 4.), Point(1., 0.), TimeInterval(0,10)), MovingObject.generate(4, Point(0., 4.), Point(1., 0.), TimeInterval(0,10))])
265 >>> o2 = MovingObject(2, TimeInterval(0,10), features=[MovingObject.generate(5, Point(6., 0.), Point(0., 1.), TimeInterval(0,10)), MovingObject.generate(6, Point(7., 0.), Point(0., 1.), TimeInterval(0,10)), MovingObject.generate(7, Point(7., 2.), Point(0., 1.), TimeInterval(0,10)), MovingObject.generate(8, Point(6., 2.), Point(0., 1.), TimeInterval(0,10))]) 265 >>> o2 = MovingObject(2, TimeInterval(0,10), features=[MovingObject.generate(5, Point(6., 0.), Point(0., 1.), TimeInterval(0,10)), MovingObject.generate(6, Point(7., 0.), Point(0., 1.), TimeInterval(0,10)), MovingObject.generate(7, Point(7., 2.), Point(0., 1.), TimeInterval(0,10)), MovingObject.generate(8, Point(6., 2.), Point(0., 1.), TimeInterval(0,10))])
266 >>> MovingObject.computePET(o1, o2, useBoundingPoly = True) 266 >>> MovingObject.computePET(o1, o2, useBoundingPoly = True)
267 (2.0, 5, 3) 267 (np.float64(2.0), np.int64(5), np.int64(3))
268 268
269 >>> t1 = CurvilinearTrajectory.generate(3, 1., 10, 'b') 269 >>> t1 = CurvilinearTrajectory.generate(3, 1., 10, 'b')
270 >>> t1.length() 270 >>> t1.length()
271 10 271 10
272 >>> t1[3] 272 >>> t1[3]
333 True 333 True
334 >>> o13.getTimeInterval() == TimeInterval(0,12) 334 >>> o13.getTimeInterval() == TimeInterval(0,12)
335 True 335 True
336 >>> t=5 336 >>> t=5
337 >>> o13.getPositionAtInstant(t) == (o1.getPositionAtInstant(t)+o3.getPositionAtInstant(t)).divide(2) 337 >>> o13.getPositionAtInstant(t) == (o1.getPositionAtInstant(t)+o3.getPositionAtInstant(t)).divide(2)
338 True 338 np.True_
339 >>> len(o13.getFeatures()) 339 >>> len(o13.getFeatures())
340 2 340 2
341 341
342 >>> o12, f12 = MovingObject.concatenate(o1, o2, 15, 15) 342 >>> o12, f12 = MovingObject.concatenate(o1, o2, 15, 15)
343 >>> o12.getTimeInterval() == TimeInterval(o1.getFirstInstant(), o2.getLastInstant()) 343 >>> o12.getTimeInterval() == TimeInterval(o1.getFirstInstant(), o2.getLastInstant())
377 True 377 True
378 >>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12) 378 >>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12)
379 True 379 True
380 >>> o15.updatePositions() 380 >>> o15.updatePositions()
381 >>> o1.getPositionAtInstant(10) == o15.getPositionAtInstant(10) 381 >>> o1.getPositionAtInstant(10) == o15.getPositionAtInstant(10)
382 True 382 np.True_
383 >>> f15.getPositionAtInstant(11) == o15.getPositionAtInstant(11) 383 >>> f15.getPositionAtInstant(11) == o15.getPositionAtInstant(11)
384 True 384 np.True_
385 >>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12) 385 >>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12)
386 True 386 np.True_
387 387
388 >>> o1 = MovingObject.generate(1, Point(0., 2.), Point(0., 1.), TimeInterval(0,2)) 388 >>> o1 = MovingObject.generate(1, Point(0., 2.), Point(0., 1.), TimeInterval(0,2))
389 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.median) 389 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.median)
390 >>> userTypeNames[o1.getUserType()] 390 >>> userTypeNames[o1.getUserType()]
391 'car' 391 'car'