Merge lp:~cody-stevens/graphite/graphite into lp:graphite

Proposed by Cody Stevens on 2012-10-31
Status: Needs review
Proposed branch: lp:~cody-stevens/graphite/graphite
Merge into: lp:graphite
Diff against target: 18 lines (+2/-2)
1 file modified
webapp/graphite/render/functions.py (+2/-2)
To merge this branch: bzr merge lp:~cody-stevens/graphite/graphite
Reviewer Review Type Date Requested Status
graphite-dev 2012-10-31 Pending
Review via email: mp+132388@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Sidnei da Silva (sidnei) wrote :

Hi Cody,

Graphite's development has now moved to github (https://github.com/graphite-project/graphite-web), please submit your pull request there instead.

Unmerged revisions

865. By Cody Stevens on 2012-10-31

Updated safeDiff and safeSum to require 2 values to be summed/diffed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'webapp/graphite/render/functions.py'
2--- webapp/graphite/render/functions.py 2012-10-16 01:41:01 +0000
3+++ webapp/graphite/render/functions.py 2012-10-31 17:01:24 +0000
4@@ -46,12 +46,12 @@
5 #Utility functions
6 def safeSum(values):
7 safeValues = [v for v in values if v is not None]
8- if safeValues:
9+ if safeValues and len(safeValues) > 1:
10 return sum(safeValues)
11
12 def safeDiff(values):
13 safeValues = [v for v in values if v is not None]
14- if safeValues:
15+ if safeValues and len(safeValues) > 1:
16 values = map(lambda x: x*-1, safeValues[1:])
17 values.insert(0, safeValues[0])
18 return sum(values)

Subscribers

People subscribed via source and target branches

to all changes: