Commit 3ee220fe3a9b99b2c8acb2db2de714db63bc3548
1 parent
3b301911
Exists in
master
and in
85 other branches
covrage ok
Showing
2 changed files
with
39 additions
and
39 deletions
Show diff stats
src/ExternLib/StatisticProcesses/CountBoolStatistic.hh
... | ... | @@ -34,7 +34,7 @@ namespace AMDA { |
34 | 34 | typedef typename TParamData::ElementType ElementType; |
35 | 35 | |
36 | 36 | CountStatisticOperation(StatisticProcess& process, |
37 | - TimeIntervalListSPtr pTimeIntervalList, TParamData ¶m, COUNT_BOOL_FUNC_TYPE funcType) : | |
37 | + TimeIntervalListSPtr pTimeIntervalList, TParamData ¶m, COUNT_BOOL_FUNC_TYPE funcType) : | |
38 | 38 | StatisticOperation<TResultData>(process), |
39 | 39 | _paramInput(param), _timeIntervalList(pTimeIntervalList), |
40 | 40 | _currentTimeInterval(_timeIntervalList->begin()), |
... | ... | @@ -60,7 +60,7 @@ namespace AMDA { |
60 | 60 | } |
61 | 61 | |
62 | 62 | virtual void finalizeCompute(void) { |
63 | - finalizeCountResult(StatisticOperation<TResultData>::_resultData); | |
63 | + // do nothing averything is ok | |
64 | 64 | } |
65 | 65 | |
66 | 66 | virtual std::string getResultDimDefinition(bool /* forCoverage */) { |
... | ... | @@ -83,54 +83,50 @@ namespace AMDA { |
83 | 83 | void resetData(std::vector<Type> &a) { |
84 | 84 | a.clear(); |
85 | 85 | } |
86 | - template<typename Type> | |
86 | + | |
87 | + template<typename Type> | |
87 | 88 | void countTrue(Type &a) { |
88 | 89 | _dimDef.str("1"); |
89 | - if(typeid(a) != typeid( AMDA::Parameters::LogicalData)){ | |
90 | + if (typeid (a) != typeid ( AMDA::Parameters::LogicalData)) { | |
90 | 91 | BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Only boolean params are supported supported")); |
91 | 92 | return; |
92 | 93 | } |
94 | + if (isNAN(StatisticOperation<TResultData>::_resultData._result)) | |
95 | + StatisticOperation<TResultData>::_resultData._result = 0; | |
96 | + ++StatisticOperation<TResultData>::_resultData._nbDataProcessed; | |
93 | 97 | if (isNAN(a) || a != AMDA::Parameters::LogicalData::True) |
94 | 98 | return; |
95 | - ++StatisticOperation<TResultData>::_resultData._nbDataProcessed; | |
99 | + ++StatisticOperation<TResultData>::_resultData._result; | |
96 | 100 | } |
97 | - | |
98 | - template<typename Type> | |
101 | + | |
102 | + template<typename Type> | |
99 | 103 | void countTrue(std::vector<Type> &a) { |
100 | 104 | if (StatisticOperation<TResultData>::_resultData.empty()) { |
101 | 105 | _dimDef.str(""); |
102 | 106 | _dimDef << a.size(); |
103 | 107 | for (unsigned int i = 0; i < a.size(); ++i) { |
104 | - if(typeid(a[i]) != typeid( AMDA::Parameters::LogicalData)){ | |
105 | - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Only boolean params are supported supported")); | |
106 | - return; | |
108 | + if (typeid (a[i]) != typeid ( AMDA::Parameters::LogicalData)) { | |
109 | + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Only boolean params are supported supported")); | |
110 | + return; | |
107 | 111 | } |
108 | - StatisticDataScalar<int> data; | |
112 | + StatisticDataScalar<int> data; | |
109 | 113 | resetData(data); |
110 | - if (!isNAN(a[i]) && (int) a[i] == AMDA::Parameters::LogicalData::True) | |
111 | - ++data._nbDataProcessed; | |
114 | + ++data._nbDataProcessed; | |
115 | + data._result = 0; | |
116 | + if (!isNAN(a[i]) && (int) a[i] == AMDA::Parameters::LogicalData::True) | |
117 | + ++ data._result; | |
112 | 118 | StatisticOperation<TResultData>::_resultData.push_back(data); |
113 | 119 | } |
114 | 120 | return; |
115 | 121 | } |
116 | 122 | for (unsigned int i = 0; i < StatisticOperation<TResultData>::_resultData.size(); ++i) { |
117 | - if (isNAN(a[i]) && a[i] != AMDA::Parameters::LogicalData::True) | |
123 | + if (isNAN(a[i])) | |
118 | 124 | continue; |
119 | 125 | ++StatisticOperation<TResultData>::_resultData[i]._nbDataProcessed; |
126 | + if (a[i] == AMDA::Parameters::LogicalData::True) | |
127 | + ++StatisticOperation<TResultData>::_resultData[i]._result; | |
120 | 128 | } |
121 | 129 | } |
122 | - | |
123 | - template<typename Type> | |
124 | - void finalizeCountResult(Type &a) { | |
125 | - if (!isNAN(a._nbDataProcessed)) | |
126 | - a._result = a._nbDataProcessed; | |
127 | - } | |
128 | - | |
129 | - template<typename Type> | |
130 | - void finalizeCountResult(std::vector<Type> &a) { | |
131 | - for (int i = 0; i < a.size(); i++) | |
132 | - finalizeCountResult(a[i]); | |
133 | - } | |
134 | 130 | |
135 | 131 | /** |
136 | 132 | * @brief real ParamData Input |
... | ... | @@ -143,7 +139,7 @@ namespace AMDA { |
143 | 139 | |
144 | 140 | ElementType _val; |
145 | 141 | |
146 | - COUNT_BOOL_FUNC_TYPE _funcType; | |
142 | + COUNT_BOOL_FUNC_TYPE _funcType; | |
147 | 143 | |
148 | 144 | std::stringstream _dimDef; |
149 | 145 | |
... | ... | @@ -168,7 +164,7 @@ namespace AMDA { |
168 | 164 | * @overload VisitorOfParamData::visit(ParamDataScalaireShort *) |
169 | 165 | */ |
170 | 166 | virtual void visit(ParamDataScalaireShort *) { |
171 | - BOOST_THROW_EXCEPTION( | |
167 | + BOOST_THROW_EXCEPTION( | |
172 | 168 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
173 | 169 | << AMDA::ex_msg( |
174 | 170 | "CreateStatistic operation not supported")); |
... | ... | @@ -178,7 +174,7 @@ namespace AMDA { |
178 | 174 | * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *) |
179 | 175 | */ |
180 | 176 | virtual void visit(ParamDataScalaireFloat *) { |
181 | - BOOST_THROW_EXCEPTION( | |
177 | + BOOST_THROW_EXCEPTION( | |
182 | 178 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
183 | 179 | << AMDA::ex_msg( |
184 | 180 | "CreateStatistic operation not supported")); |
... | ... | @@ -188,7 +184,7 @@ namespace AMDA { |
188 | 184 | * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *) |
189 | 185 | */ |
190 | 186 | virtual void visit(ParamDataScalaireDouble *) { |
191 | - BOOST_THROW_EXCEPTION( | |
187 | + BOOST_THROW_EXCEPTION( | |
192 | 188 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
193 | 189 | << AMDA::ex_msg( |
194 | 190 | "CreateStatistic operation not supported")); |
... | ... | @@ -198,7 +194,7 @@ namespace AMDA { |
198 | 194 | * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *) |
199 | 195 | */ |
200 | 196 | virtual void visit(ParamDataScalaireLongDouble *) { |
201 | - BOOST_THROW_EXCEPTION( | |
197 | + BOOST_THROW_EXCEPTION( | |
202 | 198 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
203 | 199 | << AMDA::ex_msg( |
204 | 200 | "CreateStatistic operation not supported")); |
... | ... | @@ -208,7 +204,7 @@ namespace AMDA { |
208 | 204 | * @overload VisitorOfParamData::visit(ParamDataScalaireInt *) |
209 | 205 | */ |
210 | 206 | virtual void visit(ParamDataScalaireInt *) { |
211 | - BOOST_THROW_EXCEPTION( | |
207 | + BOOST_THROW_EXCEPTION( | |
212 | 208 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
213 | 209 | << AMDA::ex_msg( |
214 | 210 | "CreateStatistic operation not supported")); |
... | ... | @@ -218,7 +214,7 @@ namespace AMDA { |
218 | 214 | * @overload VisitorOfParamData::visit(ParamDataLogicalData *) |
219 | 215 | */ |
220 | 216 | virtual void visit(ParamDataLogicalData *) { |
221 | - _operation = new CountStatisticOperation<ParamDataLogicalData, StatisticDataScalar<int>>(_process, | |
217 | + _operation = new CountStatisticOperation<ParamDataLogicalData, StatisticDataScalar<int>>(_process, | |
222 | 218 | _timeIntervalList, dynamic_cast<ParamDataLogicalData &> (_paramData), _type); |
223 | 219 | } |
224 | 220 | |
... | ... | @@ -226,7 +222,7 @@ namespace AMDA { |
226 | 222 | * @overload VisitorOfParamData::visit(ParamDataTab1DShort *) |
227 | 223 | */ |
228 | 224 | virtual void visit(ParamDataTab1DShort *) { |
229 | - BOOST_THROW_EXCEPTION( | |
225 | + BOOST_THROW_EXCEPTION( | |
230 | 226 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
231 | 227 | << AMDA::ex_msg( |
232 | 228 | "CreateStatistic operation not supported")); |
... | ... | @@ -236,7 +232,7 @@ namespace AMDA { |
236 | 232 | * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *) |
237 | 233 | */ |
238 | 234 | virtual void visit(ParamDataTab1DFloat *) { |
239 | - BOOST_THROW_EXCEPTION( | |
235 | + BOOST_THROW_EXCEPTION( | |
240 | 236 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
241 | 237 | << AMDA::ex_msg( |
242 | 238 | "CreateStatistic operation not supported")); |
... | ... | @@ -246,7 +242,7 @@ namespace AMDA { |
246 | 242 | * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *) |
247 | 243 | */ |
248 | 244 | virtual void visit(ParamDataTab1DDouble *) { |
249 | - BOOST_THROW_EXCEPTION( | |
245 | + BOOST_THROW_EXCEPTION( | |
250 | 246 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
251 | 247 | << AMDA::ex_msg( |
252 | 248 | "CreateStatistic operation not supported")); |
... | ... | @@ -256,7 +252,7 @@ namespace AMDA { |
256 | 252 | * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *) |
257 | 253 | */ |
258 | 254 | virtual void visit(ParamDataTab1DLongDouble *) { |
259 | - BOOST_THROW_EXCEPTION( | |
255 | + BOOST_THROW_EXCEPTION( | |
260 | 256 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
261 | 257 | << AMDA::ex_msg( |
262 | 258 | "CreateStatistic operation not supported")); |
... | ... | @@ -266,7 +262,7 @@ namespace AMDA { |
266 | 262 | * @overload VisitorOfParamData::visit(ParamDataTab1DInt *) |
267 | 263 | */ |
268 | 264 | virtual void visit(ParamDataTab1DInt *) { |
269 | - BOOST_THROW_EXCEPTION( | |
265 | + BOOST_THROW_EXCEPTION( | |
270 | 266 | AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) |
271 | 267 | << AMDA::ex_msg( |
272 | 268 | "CreateStatistic operation not supported")); |
... | ... | @@ -276,7 +272,7 @@ namespace AMDA { |
276 | 272 | * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *) |
277 | 273 | */ |
278 | 274 | virtual void visit(ParamDataTab1DLogicalData *) { |
279 | - _operation = new CountStatisticOperation<ParamDataTab1DLogicalData, StatisticDataVector<int>>(_process, | |
275 | + _operation = new CountStatisticOperation<ParamDataTab1DLogicalData, StatisticDataVector<int>>(_process, | |
280 | 276 | _timeIntervalList, dynamic_cast<ParamDataTab1DLogicalData &> (_paramData), _type); |
281 | 277 | } |
282 | 278 | ... | ... |
src/ExternLib/StatisticProcesses/MinMaxMeanStatistic.hh
... | ... | @@ -318,6 +318,7 @@ namespace AMDA { |
318 | 318 | if (isNAN(StatisticOperation<TResultData>::_resultData._result)) |
319 | 319 | StatisticOperation<TResultData>::_resultData._result = a; |
320 | 320 | _dataList.push_back(a); |
321 | + ++StatisticOperation<TResultData>::_resultData._nbDataProcessed; | |
321 | 322 | } |
322 | 323 | |
323 | 324 | template<typename Type> |
... | ... | @@ -333,6 +334,7 @@ namespace AMDA { |
333 | 334 | if (!isNAN(a)) |
334 | 335 | ++data._nbDataProcessed; |
335 | 336 | StatisticOperation<TResultData>::_resultData.push_back(data); |
337 | + | |
336 | 338 | } |
337 | 339 | } |
338 | 340 | |
... | ... | @@ -344,12 +346,14 @@ namespace AMDA { |
344 | 346 | vec.push_back(a[i]); |
345 | 347 | _dataList.push_back(vec); |
346 | 348 | vec.clear(); |
349 | + ++StatisticOperation<TResultData>::_resultData[i]._nbDataProcessed; | |
347 | 350 | } |
348 | 351 | } else { |
349 | 352 | //remplir dataList |
350 | 353 | for (int i = 0; i < a.size(); i++) { |
351 | 354 | if (!isNAN(a[i])) |
352 | 355 | _dataList[i].push_back(a[i]); |
356 | + ++StatisticOperation<TResultData>::_resultData[i]._nbDataProcessed; | |
353 | 357 | } |
354 | 358 | } |
355 | 359 | ... | ... |