nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6064cf2
)
metrics: skip `not a number` values when computinh the sum and std_dev
author
Alexandre Terrasa
<alexandre@moz-code.org>
Thu, 15 Oct 2015 21:41:50 +0000
(17:41 -0400)
committer
Alexandre Terrasa
<alexandre@moz-code.org>
Thu, 15 Oct 2015 21:41:50 +0000
(17:41 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
src/metrics/metrics_base.nit
patch
|
blob
|
history
diff --git
a/src/metrics/metrics_base.nit
b/src/metrics/metrics_base.nit
index
605f4d3
..
ebd05ae
100644
(file)
--- a/
src/metrics/metrics_base.nit
+++ b/
src/metrics/metrics_base.nit
@@
-299,7
+299,10
@@
class FloatMetric
redef fun sum do
var sum = 0.0
- for v in values.values do sum += v
+ for v in values.values do
+ if v.is_nan then continue
+ sum += v
+ end
return sum
end
@@
-337,6
+340,7
@@
class FloatMetric
redef fun std_dev do
var sum = 0.0
for value in values.values do
+ if value.is_nan then continue
sum += (value - avg).pow(2.to_f)
end
return (sum / values.length.to_f).sqrt