def finalize(self):
        if self.ct == 0:
            return
        elif self.ct == 1:
            return 0

        total = ct = 0
        prev = None
        while self.heap:
            if total == 0:
                if prev is None:
                    prev = heapq.heappop(self.heap)
                    continue

            curr = heapq.heappop(self.heap)
            diff = prev - curr
            ct += 1
            total += diff
            prev = curr

        return float(total) / ct
dataset/ETHPy150Open coleifer/peewee/playhouse/sqlite_udf.py/avgrange.finalize/swapped operands of `-`