def op(self):
        if self.candidates:
            e = self.candidates.pop()
            self.set.add(e)
            return e
        while True:
            active = False
            for v in self.iters:
                if not self.final[id(v)]:
                    try:
                        n = v.next()
                        if isinstance(n, InfiniteElement):
                            self.infs[id(v)] = True
                            self.final[id(v)] = True
                        self.drawn[id(v)].add(n)
                        active = True
                    except PauseIteration:
                        pass
                    except StopIteration:
                        self.final[id(v)] = True
            if all(self.infs.values()):
                self.infinite_set = True
                if self.infinite_sent:
                    _log.debug(self.__str__() % "%s INFINITE STOP")
                    raise StopIteration
                else:
                    _log.debug("%s INFINITE SEND" % self.__str__())
                    self.infinite_sent = True
                    # FIXME Need to trig?
                    #self.trig()
                    return InfiniteElement
                
            # Current seen intersection
            self.candidates.update(set.intersection(*[self.drawn[id(v)] for v in self.iters if not self.infs[id(v)]]))
            _log.debug("Intersection%s%s%s candidates: %s drawn: %s infs: %s"  % (("<" + self.name + ">") if self.name else "",
                                           "<Inf>" if self.infinite_set else "",
                                           "#" if self._final else "-", self.candidates, self.drawn.values(), self.infs.values()))
            # remove from individual iterables
            for v in self.drawn.values():
                v.difference_update(self.candidates)
            # Remove previously seen
            self.candidates.difference_update(self.set)
            if self.candidates:
                e = self.candidates.pop()
                self.set.add(e)
                return e
            if not active or all(self.final.values()):
                break
        if all([self.final[id(v)] for v in self.iters]):
            self._final = True
            raise StopIteration
        else:
            raise PauseIteration
dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/utilities/dynops.py/Intersection.op/swapped operands of `%`