How to use the eventkit.util.NO_VALUE function in eventkit

To help you get started, we’ve selected a few eventkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github erdewit / eventkit / eventkit / ops / array.py View on Github external
def on_source(self, *args):
        self._q.append(
            args[0] if len(args) == 1 else args if args else NO_VALUE)
        if self._count and len(self._q) > self._count:
            self._q.popleft()
        self.emit(np.asarray(self._q))
github erdewit / eventkit / eventkit / ops / combine.py View on Github external
def _on_source_i(self, i, *args):
        q = self._results[i]
        if not q:
            self._num_ready += 1
            ready = self._num_ready == len(self._results)
        else:
            ready = False
        q.append(args[0] if len(args) == 1 else args if args else NO_VALUE)
        if ready:
            tup = tuple(q.popleft() for q in self._results)
            self._num_ready = sum(bool(q) for q in self._results)
            self.emit(*tup)
github erdewit / eventkit / eventkit / ops / aggregate.py View on Github external
def on_source(self, arg):
        if self._prev is NO_VALUE:
            if self._initializer is NO_VALUE:
                self._prev = arg
            else:
                self._prev = self._func(self._initializer, arg)
                self.emit(self._prev)
        else:
            self._prev = self._func(self._prev, arg)
            self.emit(self._prev)
github erdewit / eventkit / eventkit / event.py View on Github external
self.error_event = None
        """
        Sub event that emits errors from this event as
        ``emit(source, exception)``.
        """
        self.done_event = None
        """
        Sub event that emits when this event is done as
        ``emit(source)``.
        """
        if _with_error_done_events:
            self.error_event = Event('error', False)
            self.done_event = Event('done', False)
        self._slots = []  # list of [obj, weakref, func] sublists
        self._name = name or self.__class__.__qualname__
        self._value = NO_VALUE
        self._done = False
        self._source = None
github erdewit / eventkit / eventkit / ops / combine.py View on Github external
def _on_source_i(self, i, *args):
        self._values[i] = \
            args[0] if len(args) == 1 else args if args else NO_VALUE
        if not self._is_primed:
            self._is_primed = not any(r is NO_VALUE for r in self._values)
        if self._is_primed:
            self.emit(*self._values)
github erdewit / eventkit / eventkit / ops / aggregate.py View on Github external
def on_source(self, *args):
        value = args[0] if len(args) == 1 else args if args else NO_VALUE
        if self._has_prev:
            self.emit(self._prev, value)
        else:
            self._has_prev = True
        self._prev = value
github erdewit / eventkit / eventkit / ops / timing.py View on Github external
def _on_timer(self, *args):
        if self._value is not NO_VALUE:
            self.emit(*self._value)
github erdewit / eventkit / eventkit / event.py View on Github external
    def reduce(self, func, initializer=NO_VALUE) -> "Reduce":
        """
        Apply a two-argument reduction function to the previous reduction
        result and the current value and emit the new reduction result.

        Args:
            func: Reduction function::

                emit(args) -> emit(func(prev_args, args))

            initializer: First argument of first reduction::

                    first_result = func(initializer, first_value)

                If no initializer is given, then the first result is
                emitted on the second source emit.
        """
github erdewit / eventkit / eventkit / ops / aggregate.py View on Github external
    def __init__(self, func, initializer=NO_VALUE, source=None):
        Op.__init__(self, source)
        self._func = func
        self._initializer = initializer
        self._prev = NO_VALUE
github erdewit / eventkit / eventkit / ops / aggregate.py View on Github external
def __init__(self, n=None, weight=None, source=None):
        Op.__init__(self, source)
        self._f1 = weight or 2.0 / (n + 1)
        self._f2 = 1 - self._f1
        self._prev = NO_VALUE