annotate python/tests/moving.txt @ 107:916678481896

corrected bug for TimeInterval interation and added corresponding test
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 15 Jul 2011 02:32:34 -0400
parents 13187af8622d
children 606010d1d9a4
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
43
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
32 >>> Point(3,4)-Point(1,7)
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
33 (2.000000,-3.000000)
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
34
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
35 >>> Point(3,2).norm2Squared()
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
36 13
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
37
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
38 >>> Point.distanceNorm2(Point(3,4),Point(1,7))
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
39 3.6055512754639891
6d11d9e7ad4e methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
40
79
5d487f183fe2 added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 69
diff changeset
41 >>> 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
42 False
5d487f183fe2 added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 69
diff changeset
43 >>> 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
44 True
5d487f183fe2 added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 69
diff changeset
45
69
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
46 >>> 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
47 >>> 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
48 True
69
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
49 >>> t1[1]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
50 (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
51 >>> 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
52 (0.500000,0.500000)
69
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
53
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
54 >>> indic1 = TemporalIndicator('bla', [0,3,-4], TimeInterval(4,6))
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
55 >>> indic1.empty()
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
56 False
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
57 >>> indic1[5]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
58 3
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
59 >>> indic1[3]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
60 >>> [v for v in indic1]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
61 [0, 3, -4]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
62 >>> indic1 = TemporalIndicator('bla', {2:0,4:3,5:-5})
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
63 >>> indic1[4]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
64 3
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
65 >>> indic1[3]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
66 >>> [v for v in indic1]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
67 [0, 3, -5]
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
68
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
69 >>> indicatorMap([1,2,3], t1, 1)
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
70 {(1.0, 3.0): 2.0, (2.0, 6.0): 3.0, (0.0, 0.0): 1.0}
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
71 >>> indicatorMap([1,2,3], t1, 4)
cc192d0450b3 added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 43
diff changeset
72 {(0.0, 1.0): 3.0, (0.0, 0.0): 1.5}