Skip to content

Commit

Permalink
Min and max accumulators didn't return correct results in all cases. C…
Browse files Browse the repository at this point in the history
…loses #21.
  • Loading branch information
tshead2 committed Jul 18, 2013
1 parent 2783d1b commit 2554d13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions analysis-server/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def test_aggregate_max():
require_array_schema(array2, [("i", "int64", 0, 1, 1)], [("val_max", "float64")])
numpy.testing.assert_array_almost_equal(value(array2), values(array1).max())

def test_aggregate_max_2():
array1 = random(50, 10)
array2 = aggregate(array1, ["max(val)"])
require_array_schema(array2, [("i", "int64", 0, 1, 1)], [("val_max", "float64")])
numpy.testing.assert_array_almost_equal(value(array2), values(array1).max())

def test_aggregate_min():
array1 = random(5, 3)
array2 = aggregate(array1, ["min(val)"])
Expand Down
4 changes: 2 additions & 2 deletions packages/slycat/analysis/worker/accumulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class maximum(accumulator):
def __init__(self):
self.max = None
def accumulate(self, observations):
self.max = observations.max() if self.max is None else max(self.max, observations.max)
self.max = observations.max() if self.max is None else max(self.max, observations.max())
def reduce(self, other):
self.max = other.max if self.max is None else self.max if other.max is None else max(self.max, other.max)
def result(self):
Expand All @@ -83,7 +83,7 @@ class minimum(accumulator):
def __init__(self):
self.min = None
def accumulate(self, observations):
self.min = observations.min() if self.min is None else min(self.min, observations.min)
self.min = observations.min() if self.min is None else min(self.min, observations.min())
def reduce(self, other):
self.min = other.min if self.min is None else self.min if other.min is None else min(self.min, other.min)
def result(self):
Expand Down

0 comments on commit 2554d13

Please sign in to comment.