view python/tests/moving.txt @ 190:36968a63efe1

Got the connected_components to finally work using a vecS for the vertex list in the adjacency list. In this case, the component map is simply a vector of ints (which is the type of UndirectedGraph::vextex_descriptor (=graph_traits<FeatureGraph>::vertex_descriptor) and probably UndirectedGraph::vertices_size_type). To use listS, I was told on the Boost mailing list: >> If you truly need listS, you will need to create a vertex index >> map, fill it in before you create the property map, and pass it to the >> vector_property_map constructor (and as a type argument to that class). It may be feasible with a component map like shared_array_property_map< graph_traits<FeatureGraph>::vertex_descriptor, property_map<FeatureGraph, vertex_index_t>::const_type > components(num_vertices(g), get(vertex_index, g));
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 07 Dec 2011 18:51:32 -0500
parents 74b1fc68d4df
children 571ba5ed22e2
line wrap: on
line source

>>> from moving import *
>>> import numpy as np

>>> Interval().empty()
True
>>> Interval(0,1).empty()
False
>>> Interval(0,1)
[0, 1]
>>> Interval(0,1).length()
1.0
>>> Interval(23.2,24.9).length()
1.6999999999999993
>>> Interval(10,8).length()
0.0

>>> TimeInterval(0,1).length()
2.0
>>> TimeInterval(10,8).length()
0.0

>>> [i for i in TimeInterval(9,13)]
[9, 10, 11, 12, 13]

>>> TimeInterval(2,5).equal(TimeInterval(2,5))
True
>>> TimeInterval(2,5).equal(TimeInterval(2,4))
False
>>> TimeInterval(2,5).equal(TimeInterval(5,2))
False

>>> Point(3,4)-Point(1,7)
(2.000000,-3.000000)

>>> Point(3,2).norm2Squared()
13

>>> Point.distanceNorm2(Point(3,4),Point(1,7))
3.6055512754639891

>>> Point(3,2).inPolygon([Point(0,0),Point(1,0),Point(1,1),Point(0,1)])
False
>>> Point(3,2).inPolygon([Point(0,0),Point(4,0),Point(4,3),Point(0,3)])
True

>>> segmentIntersection(Point(0,0),Point(1,1), Point(0,1), Point(1,2))
>>> segmentIntersection(Point(0,1),Point(1,0), Point(0,2), Point(2,1))
>>> segmentIntersection(Point(0,0),Point(2,0), Point(1,-1),Point(1,1))
(1.000000,0.000000)
>>> segmentIntersection(Point(0,1),Point(2,0),Point(1,1),Point(1,2))

>>> Trajectory().length()
0
>>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]])
>>> t1.length() == 3.
True
>>> t1[1]
(1.500000,3.500000)
>>> t1.getTrajectoryInPolygon(np.array([[0,0],[4,0],[4,3],[0,3]]))
(0.500000,0.500000)
>>> t1.getTrajectoryInPolygon(np.array([[10,10],[14,10],[14,13],[10,13]])).length()
0

>>> indic1 = TemporalIndicator('bla', [0,3,-4], TimeInterval(4,6))
>>> indic1.empty()
False
>>> indic1[5]
3
>>> indic1[3]
>>> [v for v in indic1]
[0, 3, -4]
>>> indic1 = TemporalIndicator('bla', {2:0,4:3,5:-5})
>>> indic1[4]
3
>>> indic1[3]
>>> [v for v in indic1]
[0, 3, -5]

>>> indicatorMap([1,2,3], t1, 1)
{(1.0, 3.0): 2.0, (2.0, 6.0): 3.0, (0.0, 0.0): 1.0}
>>> indicatorMap([1,2,3], t1, 4)
{(0.0, 1.0): 3.0, (0.0, 0.0): 1.5}