diff --git a/dap/algos/aggregation.py b/dap/algos/aggregation.py index 87987fd..f7d3e71 100644 --- a/dap/algos/aggregation.py +++ b/dap/algos/aggregation.py @@ -51,8 +51,9 @@ def calc_aggregate(results, data, aggregator): def calc_aggregation_ready(results, aggregator): - aggregation_max = results.get("aggregation_max") - if not aggregator.is_ready(aggregation_max): + aggregator.nmax = results.get("aggregation_max") + + if not aggregator.is_ready(): return False aggregator.reset() diff --git a/dap/utils/aggregator.py b/dap/utils/aggregator.py index d1f18f7..03f7ba8 100644 --- a/dap/utils/aggregator.py +++ b/dap/utils/aggregator.py @@ -7,6 +7,7 @@ class Aggregator: def reset(self): self.data = None self.counter = 0 + self.nmax = None def add(self, item): if self.data is None: @@ -19,13 +20,13 @@ class Aggregator: __iadd__ = add - def is_ready(self, nmax): - if nmax is None: + def is_ready(self): + if self.nmax is None: return False - return (self.counter >= nmax) + return (self.counter >= self.nmax) def __repr__(self): - return f"{self.data!r} / {self.counter}" + return f"{self.data!r} # ({self.counter} / {self.nmax})"