Mercurial Hosting > traffic-intelligence
annotate python/indicators.py @ 700:0f1b6907643a dev
merged improvement from stable
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 17 Jul 2015 14:33:01 -0400 |
parents | 5ee22bf7e4d5 |
children | b75d0c258ca9 |
rev | line source |
---|---|
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 #! /usr/bin/env python |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 '''Class for indicators, temporal indicators, and safety indicators''' |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
3 |
269
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
4 import moving |
691
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
5 #import matplotlib.nxutils as nx |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
6 from matplotlib.pyplot import plot, ylim |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
7 from matplotlib.pylab import find |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
8 from numpy import array, arange, mean, floor, mean |
269
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
9 |
665
15e244d2a1b5
corrected bug with circular import for VideoFilenameAddable, moved to base module
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
661
diff
changeset
|
10 |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 # need for a class representing the indicators, their units, how to print them in graphs... |
665
15e244d2a1b5
corrected bug with circular import for VideoFilenameAddable, moved to base module
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
661
diff
changeset
|
12 class TemporalIndicator(object): |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
13 '''Class for temporal indicators |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
14 i.e. indicators that take a value at specific instants |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
16 values should be |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
17 * a dict, for the values at specific time instants |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
18 * or a list with a time interval object if continuous measurements |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
19 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
20 it should have more information like name, unit''' |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
21 |
693
5ee22bf7e4d5
corrected bug when loading indicator time intervals and updated how queries are created for better legibility
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
692
diff
changeset
|
22 def __init__(self, name, values, timeInterval = None, maxValue = None): |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
23 self.name = name |
693
5ee22bf7e4d5
corrected bug when loading indicator time intervals and updated how queries are created for better legibility
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
692
diff
changeset
|
24 if timeInterval is None: |
5ee22bf7e4d5
corrected bug when loading indicator time intervals and updated how queries are created for better legibility
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
692
diff
changeset
|
25 self.values = values |
5ee22bf7e4d5
corrected bug when loading indicator time intervals and updated how queries are created for better legibility
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
692
diff
changeset
|
26 instants = sorted(self.values.keys()) |
5ee22bf7e4d5
corrected bug when loading indicator time intervals and updated how queries are created for better legibility
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
692
diff
changeset
|
27 if len(instants) > 0: |
5ee22bf7e4d5
corrected bug when loading indicator time intervals and updated how queries are created for better legibility
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
692
diff
changeset
|
28 self.timeInterval = moving.TimeInterval(instants[0], instants[-1]) |
5ee22bf7e4d5
corrected bug when loading indicator time intervals and updated how queries are created for better legibility
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
692
diff
changeset
|
29 else: |
5ee22bf7e4d5
corrected bug when loading indicator time intervals and updated how queries are created for better legibility
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
692
diff
changeset
|
30 self.timeInterval = moving.TimeInterval() |
5ee22bf7e4d5
corrected bug when loading indicator time intervals and updated how queries are created for better legibility
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
692
diff
changeset
|
31 else: |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
32 assert len(values) == timeInterval.length() |
282
abbd4bc13dac
modified indicator class (same interface)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
269
diff
changeset
|
33 self.timeInterval = timeInterval |
abbd4bc13dac
modified indicator class (same interface)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
269
diff
changeset
|
34 self.values = {} |
abbd4bc13dac
modified indicator class (same interface)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
269
diff
changeset
|
35 for i in xrange(int(round(self.timeInterval.length()))): |
abbd4bc13dac
modified indicator class (same interface)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
269
diff
changeset
|
36 self.values[self.timeInterval[i]] = values[i] |
269
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
37 self.maxValue = maxValue |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
38 |
287
66691c06928c
first version of indicator LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
286
diff
changeset
|
39 def __len__(self): |
66691c06928c
first version of indicator LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
286
diff
changeset
|
40 return len(self.values) |
66691c06928c
first version of indicator LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
286
diff
changeset
|
41 |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
42 def empty(self): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
43 return len(self.values) == 0 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
44 |
661
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
636
diff
changeset
|
45 def __getitem__(self, t): |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
636
diff
changeset
|
46 'Returns the value at time t' |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
636
diff
changeset
|
47 if t in self.values.keys(): |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
636
diff
changeset
|
48 return self.values[t] |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
49 else: |
282
abbd4bc13dac
modified indicator class (same interface)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
269
diff
changeset
|
50 return None |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
51 |
287
66691c06928c
first version of indicator LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
286
diff
changeset
|
52 def getIthValue(self, i): |
285
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
282
diff
changeset
|
53 sortedKeys = sorted(self.values.keys()) |
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
282
diff
changeset
|
54 if 0<=i<len(sortedKeys): |
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
282
diff
changeset
|
55 return self.values[sortedKeys[i]] |
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
282
diff
changeset
|
56 else: |
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
282
diff
changeset
|
57 return None |
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
282
diff
changeset
|
58 |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
59 def __iter__(self): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
60 self.iterInstantNum = 0 # index in the interval or keys of the dict |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
61 return self |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
62 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
63 def next(self): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
64 if self.iterInstantNum >= len(self.values):#(self.timeInterval and self.iterInstantNum>=self.timeInterval.length())\ |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
65 # or (self.iterInstantNum >= self.values) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
66 raise StopIteration |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
67 else: |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
68 self.iterInstantNum += 1 |
287
66691c06928c
first version of indicator LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
286
diff
changeset
|
69 return self.getIthValue(self.iterInstantNum-1) |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
70 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
71 def getTimeInterval(self): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
72 return self.timeInterval |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
73 |
341
2f39c4ed0b62
first version of indicator saving to sqlite
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
340
diff
changeset
|
74 def getName(self): |
2f39c4ed0b62
first version of indicator saving to sqlite
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
340
diff
changeset
|
75 return self.name |
2f39c4ed0b62
first version of indicator saving to sqlite
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
340
diff
changeset
|
76 |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
77 def getValues(self): |
287
66691c06928c
first version of indicator LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
286
diff
changeset
|
78 return [self.__getitem__(t) for t in self.timeInterval] |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
79 |
408
365d8dee44f3
last changes for TRB14
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
389
diff
changeset
|
80 def plot(self, options = '', xfactor = 1., yfactor = 1., timeShift = 0, **kwargs): |
269
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
81 if self.getTimeInterval().length() == 1: |
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
82 marker = 'o' |
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
83 else: |
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
84 marker = '' |
282
abbd4bc13dac
modified indicator class (same interface)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
269
diff
changeset
|
85 time = sorted(self.values.keys()) |
408
365d8dee44f3
last changes for TRB14
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
389
diff
changeset
|
86 plot([(x+timeShift)/xfactor for x in time], [self.values[i]/yfactor for i in time], options+marker, **kwargs) |
269
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
87 if self.maxValue: |
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
88 ylim(ymax = self.maxValue) |
308
8bafd054cda4
Added a function to compute LCSS distance between two indcators
Mohamed Gomaa
parents:
282
diff
changeset
|
89 |
8bafd054cda4
Added a function to compute LCSS distance between two indcators
Mohamed Gomaa
parents:
282
diff
changeset
|
90 def valueSorted(self): |
312 | 91 ''' return the values after sort the keys in the indicator |
321
a5e40bd04cf4
rearranged LCSS indicator functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
313
diff
changeset
|
92 This should probably not be used: to delete''' |
a5e40bd04cf4
rearranged LCSS indicator functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
313
diff
changeset
|
93 print('Deprecated: values should not be accessed in this way') |
308
8bafd054cda4
Added a function to compute LCSS distance between two indcators
Mohamed Gomaa
parents:
282
diff
changeset
|
94 values=[] |
8bafd054cda4
Added a function to compute LCSS distance between two indcators
Mohamed Gomaa
parents:
282
diff
changeset
|
95 keys = self.values.keys() |
8bafd054cda4
Added a function to compute LCSS distance between two indcators
Mohamed Gomaa
parents:
282
diff
changeset
|
96 keys.sort() |
8bafd054cda4
Added a function to compute LCSS distance between two indcators
Mohamed Gomaa
parents:
282
diff
changeset
|
97 for key in keys: |
8bafd054cda4
Added a function to compute LCSS distance between two indcators
Mohamed Gomaa
parents:
282
diff
changeset
|
98 values.append(self.values[key]) |
8bafd054cda4
Added a function to compute LCSS distance between two indcators
Mohamed Gomaa
parents:
282
diff
changeset
|
99 return values |
312 | 100 |
282
abbd4bc13dac
modified indicator class (same interface)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
269
diff
changeset
|
101 |
442
eb8baa080470
generalized indicator LCSS with similarityFunc (thanks Mohamed)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
408
diff
changeset
|
102 def l1Distance(x, y): # lambda x,y:abs(x-y) |
636
3058e00887bc
removed all issues because of tests with None, using is instead of == or !=
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
103 if x is None or y is None: |
322
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
321
diff
changeset
|
104 return float('inf') |
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
321
diff
changeset
|
105 else: |
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
321
diff
changeset
|
106 return abs(x-y) |
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
321
diff
changeset
|
107 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
108 from utils import LCSS as utilsLCSS |
321
a5e40bd04cf4
rearranged LCSS indicator functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
313
diff
changeset
|
109 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
110 class LCSS(utilsLCSS): |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
111 '''Adapted LCSS class for indicators, same pattern''' |
442
eb8baa080470
generalized indicator LCSS with similarityFunc (thanks Mohamed)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
408
diff
changeset
|
112 def __init__(self, similarityFunc, delta = float('inf'), minLength = 0, aligned = False, lengthFunc = min): |
eb8baa080470
generalized indicator LCSS with similarityFunc (thanks Mohamed)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
408
diff
changeset
|
113 utilsLCSS.__init__(self, similarityFunc, delta, aligned, lengthFunc) |
376
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
114 self.minLength = minLength |
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
115 |
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
116 def checkIndicator(self, indicator): |
636
3058e00887bc
removed all issues because of tests with None, using is instead of == or !=
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
117 return indicator is not None and len(indicator) >= self.minLength |
321
a5e40bd04cf4
rearranged LCSS indicator functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
313
diff
changeset
|
118 |
375
2ea8584aa80a
making indicator LCSS work
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
370
diff
changeset
|
119 def compute(self, indicator1, indicator2, computeSubSequence = False): |
376
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
120 if self.checkIndicator(indicator1) and self.checkIndicator(indicator2): |
375
2ea8584aa80a
making indicator LCSS work
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
370
diff
changeset
|
121 return self._compute(indicator1.getValues(), indicator2.getValues(), computeSubSequence) |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
122 else: |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
123 return 0 |
322
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
321
diff
changeset
|
124 |
376
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
125 def computeNormalized(self, indicator1, indicator2, computeSubSequence = False): |
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
126 if self.checkIndicator(indicator1) and self.checkIndicator(indicator2): |
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
127 return self._computeNormalized(indicator1.getValues(), indicator2.getValues(), computeSubSequence) |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
128 else: |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
129 return 0. |
322
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
321
diff
changeset
|
130 |
376
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
131 def computeDistance(self, indicator1, indicator2, computeSubSequence = False): |
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
132 if self.checkIndicator(indicator1) and self.checkIndicator(indicator2): |
2e6b8610bcaa
work on indicator similarity
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
375
diff
changeset
|
133 return self._computeDistance(indicator1.getValues(), indicator2.getValues(), computeSubSequence) |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
134 else: |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
135 return 1. |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
136 |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
137 class SeverityIndicator(TemporalIndicator): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
138 '''Class for severity indicators |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
139 field mostSevereIsMax is True |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
140 if the most severe value taken by the indicator is the maximum''' |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
141 |
286
fa95796a76b3
simplified indicators (only non-measured values, whether measurable or not)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
285
diff
changeset
|
142 def __init__(self, name, values, timeInterval=None, mostSevereIsMax=True, maxValue = None): |
269
a9988971aac8
removed legacy code + tweaks
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
265
diff
changeset
|
143 TemporalIndicator.__init__(self, name, values, timeInterval, maxValue) |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
144 self.mostSevereIsMax = mostSevereIsMax |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
145 |
631
2d1d33ae1c69
major work on pPET and pet, issues remain for pPET computed with predicted trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
442
diff
changeset
|
146 def getMostSevereValue(self, minNInstants=1): # TODO use np.percentile |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
147 values = array(self.values.values()) |
286
fa95796a76b3
simplified indicators (only non-measured values, whether measurable or not)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
285
diff
changeset
|
148 indices = range(len(values)) |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
149 if len(indices) >= minNInstants: |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
150 values = sorted(values[indices], reverse = self.mostSevereIsMax) # inverted if most severe is max -> take the first values |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
151 return mean(values[:minNInstants]) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
152 else: |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
153 return None |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
154 |
692
9a258687af4c
corrected some errors for ttc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
691
diff
changeset
|
155 def getInstantOfMostSevereValue(self): |
9a258687af4c
corrected some errors for ttc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
691
diff
changeset
|
156 '''Returns the instant at which the indicator reaches its most severe value''' |
9a258687af4c
corrected some errors for ttc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
691
diff
changeset
|
157 if self.mostSevereIsMax: |
9a258687af4c
corrected some errors for ttc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
691
diff
changeset
|
158 return max(self.values, key=self.values.get) |
9a258687af4c
corrected some errors for ttc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
691
diff
changeset
|
159 else: |
9a258687af4c
corrected some errors for ttc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
691
diff
changeset
|
160 return min(self.values, key=self.values.get) |
9a258687af4c
corrected some errors for ttc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
691
diff
changeset
|
161 |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
162 # functions to aggregate discretized maps of indicators |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
163 # TODO add values in the cells between the positions (similar to discretizing vector graphics to bitmap) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
164 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
165 def indicatorMap(indicatorValues, trajectory, squareSize): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
166 '''Returns a dictionary |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
167 with keys for the indices of the cells (squares) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
168 in which the trajectory positions are located |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
169 at which the indicator values are attached |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
170 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
171 ex: speeds and trajectory''' |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
172 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
173 assert len(indicatorValues) == trajectory.length() |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
174 indicatorMap = {} |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
175 for k in xrange(trajectory.length()): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
176 p = trajectory[k] |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
177 i = floor(p.x/squareSize) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
178 j = floor(p.y/squareSize) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
179 if indicatorMap.has_key((i,j)): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
180 indicatorMap[(i,j)].append(indicatorValues[k]) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
181 else: |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
182 indicatorMap[(i,j)] = [indicatorValues[k]] |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
183 for k in indicatorMap.keys(): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
184 indicatorMap[k] = mean(indicatorMap[k]) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
185 return indicatorMap |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
186 |
691
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
187 # def indicatorMapFromPolygon(value, polygon, squareSize): |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
188 # '''Fills an indicator map with the value within the polygon |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
189 # (array of Nx2 coordinates of the polygon vertices)''' |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
190 # points = [] |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
191 # for x in arange(min(polygon[:,0])+squareSize/2, max(polygon[:,0]), squareSize): |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
192 # for y in arange(min(polygon[:,1])+squareSize/2, max(polygon[:,1]), squareSize): |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
193 # points.append([x,y]) |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
194 # inside = nx.points_inside_poly(array(points), polygon) |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
195 # indicatorMap = {} |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
196 # for i in xrange(len(inside)): |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
197 # if inside[i]: |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
198 # indicatorMap[(floor(points[i][0]/squareSize), floor(points[i][1]/squareSize))] = 0 |
fa9aa5f08210
cleaned imports in indicators.py
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
665
diff
changeset
|
199 # return indicatorMap |
244
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
200 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
201 def indicatorMapFromAxis(value, limits, squareSize): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
202 '''axis = [xmin, xmax, ymin, ymax] ''' |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
203 indicatorMap = {} |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
204 for x in arange(limits[0], limits[1], squareSize): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
205 for y in arange(limits[2], limits[3], squareSize): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
206 indicatorMap[(floor(x/squareSize), floor(y/squareSize))] = value |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
207 return indicatorMap |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
208 |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
209 def combineIndicatorMaps(maps, squareSize, combinationFunction): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
210 '''Puts many indicator maps together |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
211 (averaging the values in each cell |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
212 if more than one maps has a value)''' |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
213 indicatorMap = {} |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
214 for m in maps: |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
215 for k,v in m.iteritems(): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
216 if indicatorMap.has_key(k): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
217 indicatorMap[k].append(v) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
218 else: |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
219 indicatorMap[k] = [v] |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
220 for k in indicatorMap.keys(): |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
221 indicatorMap[k] = combinationFunction(indicatorMap[k]) |
5027c174ab90
moved indicators to new file, added ExtrapolatedTrajectory class to extrapolation file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
222 return indicatorMap |
247
8f0ed138d373
moved the tests for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
244
diff
changeset
|
223 |
8f0ed138d373
moved the tests for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
244
diff
changeset
|
224 if __name__ == "__main__": |
8f0ed138d373
moved the tests for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
244
diff
changeset
|
225 import doctest |
8f0ed138d373
moved the tests for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
244
diff
changeset
|
226 import unittest |
8f0ed138d373
moved the tests for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
244
diff
changeset
|
227 suite = doctest.DocFileSuite('tests/indicators.txt') |
8f0ed138d373
moved the tests for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
244
diff
changeset
|
228 unittest.TextTestRunner().run(suite) |
8f0ed138d373
moved the tests for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
244
diff
changeset
|
229 # #doctest.testmod() |
8f0ed138d373
moved the tests for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
244
diff
changeset
|
230 # #doctest.testfile("example.txt") |