How to use the numbagg.decorators.NumbaNDMoving function in numbagg

To help you get started, we’ve selected a few numbagg 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 shoyer / numbagg / numbagg / decorators.py View on Github external
return vectorize(self.func)

    def __call__(self, arr, window, min_count=None, axis=-1):
        if min_count is None:
            min_count = window
        if not 0 < window < arr.shape[axis]:
            raise ValueError("window not in valid range: {}".format(window))
        if min_count < 0:
            raise ValueError("min_count must be positive: {}".format(min_count))
        axis = _validate_axis(axis, arr.ndim)
        arr = np.moveaxis(arr, axis, -1)
        result = self.gufunc(arr, window, min_count)
        return np.moveaxis(result, -1, axis)


class NumbaNDMovingExp(NumbaNDMoving):
    def __call__(self, arr, alpha, axis=-1):
        if alpha < 0:
            raise ValueError("alpha must be positive: {}".format(alpha))
        axis = _validate_axis(axis, arr.ndim)
        arr = np.moveaxis(arr, axis, -1)
        result = self.gufunc(arr, alpha)
        return np.moveaxis(result, -1, axis)


class NumbaGroupNDReduce(object):
    def __init__(self, func, signature=DEFAULT_MOVING_SIGNATURE):
        self.func = func

        for sig in signature:
            if not isinstance(sig, tuple):
                raise TypeError(