Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion webapp/graphite/render/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2427,14 +2427,17 @@ def nonNegativeDerivative(requestContext, seriesList, maxValue=None, minValue=No


def _nonNegativeDelta(val, prev, maxValue, minValue):
if val is None:
return None, None

# ignore values larger than maxValue
if maxValue is not None and val > maxValue:
return None, None
if minValue is not None and val < minValue:
return None, None

# first reading
if None in (prev, val):
if prev is None:
return None, val

# counter increased, use the difference
Expand Down
4 changes: 4 additions & 0 deletions webapp/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,10 @@ def test_perSecond_nones(self):
result = functions.scaleToSeconds({}, functions.nonNegativeDerivative({}, seriesList), 1)
self.assertEqual(list(expected[0]), list(result[0]))

# None values should not raise TypeError when maxValue is set
result = functions.perSecond({}, seriesList, maxValue=1000)
self.assertEqual(list(expected[0]), list(result[0]))
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new maxValue regression assertion only compares the values via list(...), but doesn’t assert the full TimeSeries equality (name/start/end/step/tags). For consistency with nearby perSecond tests (e.g., test_perSecond_float / test_perSecond_max) and to ensure metadata doesn’t regress, add self.assertEqual(expected, result) (or an equivalent full-object assertion) for this new call as well.

Suggested change
self.assertEqual(list(expected[0]), list(result[0]))
self.assertEqual(list(expected[0]), list(result[0]))
self.assertEqual(expected, result)

Copilot uses AI. Check for mistakes.

def test_perSecond_max(self):
seriesList = self._gen_series_list_with_data(key='test',start=0,end=600,step=60,data=[0, 120, 240, 480, 960, 900, 120, 240, 119, 479])
expected = [TimeSeries('perSecond(test)', 0, 600, 60, [None, 2, 2, 4, None, None, None, 2, 6, 6])]
Expand Down
Loading