annotate python/tests/moving.txt @ 249:99173da7afae

corrected small bugs and typos
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 21 Jul 2012 00:50:42 -0400
parents 571ba5ed22e2
children 13ec22bec5d4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1 >>> from moving import *
92
a5ef9e40688e makes use of matplotlib function to test if point is in a polygon
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 91
diff changeset
2 >>> import numpy as np
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4 >>> Interval().empty()
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5 True
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6 >>> Interval(0,1).empty()
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7 False
104
13187af8622d finally added the representation of intervals
Nicolas Saunier <nico@confins.net>
parents: 96
diff changeset
8 >>> Interval(0,1)
13187af8622d finally added the representation of intervals
Nicolas Saunier <nico@confins.net>
parents: 96
diff changeset
9 [0, 1]
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
10 >>> Interval(0,1).length()
91
daa05fae1a70 modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 79
diff changeset
11 1.0
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
12 >>> Interval(23.2,24.9).length()
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
13 1.6999999999999993
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
14 >>> Interval(10,8).length()
91
daa05fae1a70 modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 79
diff changeset
15 0.0
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
16
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
17 >>> TimeInterval(0,1).length()
91
daa05fae1a70 modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 79
diff changeset
18 2.0
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
19 >>> TimeInterval(10,8).length()
91
daa05fae1a70 modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 79
diff changeset
20 0.0
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
21
107
916678481896 corrected bug for TimeInterval interation and added corresponding test
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 104
diff changeset
22 >>> [i for i in TimeInterval(9,13)]
916678481896 corrected bug for TimeInterval interation and added corresponding test
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 104
diff changeset
23 [9, 10, 11, 12, 13]
916678481896 corrected bug for TimeInterval interation and added corresponding test
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 104
diff changeset
24
96
9928c2fa72cc added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 92
diff changeset
25 >>> TimeInterval(2,5).equal(TimeInterval(2,5))
9928c2fa72cc added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 92
diff changeset
26 True
9928c2fa72cc added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 92
diff changeset
27 >>> TimeInterval(2,5).equal(TimeInterval(2,4))
9928c2fa72cc added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 92
diff changeset
28 False
9928c2fa72cc added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 92
diff changeset
29 >>> TimeInterval(2,5).equal(TimeInterval(5,2))
9928c2fa72cc added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 92
diff changeset
30 False
9928c2fa72cc added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 92
diff changeset
31
248
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
32 >>> TimeInterval(3,6).distance(TimeInterval(4,6))
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
33 0
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
34 >>> TimeInterval(3,6).distance(TimeInterval(6,10))
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
35 0
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
36 >>> TimeInterval(3,6).distance(TimeInterval(8,10))
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
37 2
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
38 >>> TimeInterval(20,30).distance(TimeInterval(3,15))
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
39 5
249
99173da7afae corrected small bugs and typos
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 248
diff changeset
40 >>> unionIntervals([TimeInterval(3,6), TimeInterval(8,10),TimeInterval(11,15)])
99173da7afae corrected small bugs and typos
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 248
diff changeset
41 [3, 15]
248
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
42
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
43 >>> Point(3,4)-Point(1,7)
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
44 (2.000000,-3.000000)
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
45
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
46 >>> Point(3,2).norm2Squared()
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
47 13
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
48
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
49 >>> Point.distanceNorm2(Point(3,4),Point(1,7))
248
571ba5ed22e2 added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 152
diff changeset
50 3.605551275463989
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
51
79
5d487f183fe2 added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 69
diff changeset
52 >>> Point(3,2).inPolygon([Point(0,0),Point(1,0),Point(1,1),Point(0,1)])
5d487f183fe2 added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 69
diff changeset
53 False
5d487f183fe2 added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 69
diff changeset
54 >>> Point(3,2).inPolygon([Point(0,0),Point(4,0),Point(4,3),Point(0,3)])
5d487f183fe2 added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 69
diff changeset
55 True
5d487f183fe2 added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 69
diff changeset
56
249
99173da7afae corrected small bugs and typos
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 248
diff changeset
57 >>> predictPosition(10, Point(0,0), Point(1,1)) # doctest:+ELLIPSIS
99173da7afae corrected small bugs and typos
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 248
diff changeset
58 (10...,10...)
99173da7afae corrected small bugs and typos
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 248
diff changeset
59
152
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 113
diff changeset
60 >>> segmentIntersection(Point(0,0),Point(1,1), Point(0,1), Point(1,2))
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 113
diff changeset
61 >>> segmentIntersection(Point(0,1),Point(1,0), Point(0,2), Point(2,1))
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 113
diff changeset
62 >>> segmentIntersection(Point(0,0),Point(2,0), Point(1,-1),Point(1,1))
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 113
diff changeset
63 (1.000000,0.000000)
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 113
diff changeset
64 >>> segmentIntersection(Point(0,1),Point(2,0),Point(1,1),Point(1,2))
74b1fc68d4df re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 113
diff changeset
65
113
606010d1d9a4 corrected errors in trajectories (if empty) and getTrajectoryInPolygon
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 107
diff changeset
66 >>> Trajectory().length()
606010d1d9a4 corrected errors in trajectories (if empty) and getTrajectoryInPolygon
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 107
diff changeset
67 0
69
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
68 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]])
91
daa05fae1a70 modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 79
diff changeset
69 >>> t1.length() == 3.
daa05fae1a70 modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 79
diff changeset
70 True
69
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
71 >>> t1[1]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
72 (1.500000,3.500000)
92
a5ef9e40688e makes use of matplotlib function to test if point is in a polygon
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 91
diff changeset
73 >>> t1.getTrajectoryInPolygon(np.array([[0,0],[4,0],[4,3],[0,3]]))
79
5d487f183fe2 added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 69
diff changeset
74 (0.500000,0.500000)
113
606010d1d9a4 corrected errors in trajectories (if empty) and getTrajectoryInPolygon
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 107
diff changeset
75 >>> t1.getTrajectoryInPolygon(np.array([[10,10],[14,10],[14,13],[10,13]])).length()
606010d1d9a4 corrected errors in trajectories (if empty) and getTrajectoryInPolygon
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 107
diff changeset
76 0