graphite-dev team mailing list archive
-
graphite-dev team
-
Mailing list archive
-
Message #03334
[Merge] lp:~cody-stevens/graphite/graphite into lp:graphite
Cody Stevens has proposed merging lp:~cody-stevens/graphite/graphite into lp:graphite.
Requested reviews:
graphite-dev (graphite-dev)
For more details, see:
https://code.launchpad.net/~cody-stevens/graphite/graphite/+merge/132388
Graphite usually treats 'None' values as missing data which results in breaks in the lines of the graph. However, the sum and diff functions will basically treat them as a 0 value which can make the graph inaccurate when adding or diffing 2 series. This update checks to make sure that there are at least 2 values to be summed or diffed and if not will not do the diff/sum. This falls more in line with the way that graphite handles 'None' values IMHO.
--
https://code.launchpad.net/~cody-stevens/graphite/graphite/+merge/132388
Your team graphite-dev is requested to review the proposed merge of lp:~cody-stevens/graphite/graphite into lp:graphite.
=== modified file 'webapp/graphite/render/functions.py'
--- webapp/graphite/render/functions.py 2012-10-16 01:41:01 +0000
+++ webapp/graphite/render/functions.py 2012-10-31 17:01:24 +0000
@@ -46,12 +46,12 @@
#Utility functions
def safeSum(values):
safeValues = [v for v in values if v is not None]
- if safeValues:
+ if safeValues and len(safeValues) > 1:
return sum(safeValues)
def safeDiff(values):
safeValues = [v for v in values if v is not None]
- if safeValues:
+ if safeValues and len(safeValues) > 1:
values = map(lambda x: x*-1, safeValues[1:])
values.insert(0, safeValues[0])
return sum(values)
Follow ups