split updating nmax and checking readiness
This commit is contained in:
@ -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()
|
||||
|
@ -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})"
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user