How to use numbagg - 10 common examples

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 / tests.py View on Github external
numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
    numbagg.move_nanmean: wrap_pure_python(numbagg.move_nanmean.func),
}


def allclose(actual, desired, **kwargs):
    if getattr(actual, 'shape', ()) != getattr(desired, 'shape', ()):
        return False
    return np.all(np.isclose(actual, desired, equal_nan=True, **kwargs))


def check_func(numbagg_func, ref_func, x, axis):
    actual = numbagg_func(x, axis=axis)
    desired = ref_func(x, axis=axis)
    assert allclose(actual, desired), (numbagg_func, axis)


def test_funcs():
github shoyer / numbagg / numbagg / tests.py View on Github external
import numbagg

import numpy as np


def wrap_pure_python(func):
    def wrapper(x, *args, **kwargs):
        kwargs.pop('axis', None)
        out = np.empty_like(x)
        func(x, *args, out=out, **kwargs)
        return out
    return wrapper


funcs_reference_funcs = {
    numbagg.allnan: lambda x, **kwargs: np.all(np.isnan(x), **kwargs),
    numbagg.anynan: lambda x, **kwargs: np.any(np.isnan(x), **kwargs),
    numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
github shoyer / numbagg / numbagg / tests.py View on Github external
import numpy as np


def wrap_pure_python(func):
    def wrapper(x, *args, **kwargs):
        kwargs.pop('axis', None)
        out = np.empty_like(x)
        func(x, *args, out=out, **kwargs)
        return out
    return wrapper


funcs_reference_funcs = {
    numbagg.allnan: lambda x, **kwargs: np.all(np.isnan(x), **kwargs),
    numbagg.anynan: lambda x, **kwargs: np.any(np.isnan(x), **kwargs),
    numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
    numbagg.move_nanmean: wrap_pure_python(numbagg.move_nanmean.func),
github shoyer / numbagg / numbagg / tests.py View on Github external
out = np.empty_like(x)
        func(x, *args, out=out, **kwargs)
        return out
    return wrapper


funcs_reference_funcs = {
    numbagg.allnan: lambda x, **kwargs: np.all(np.isnan(x), **kwargs),
    numbagg.anynan: lambda x, **kwargs: np.any(np.isnan(x), **kwargs),
    numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
    numbagg.move_nanmean: wrap_pure_python(numbagg.move_nanmean.func),
}


def allclose(actual, desired, **kwargs):
    if getattr(actual, 'shape', ()) != getattr(desired, 'shape', ()):
        return False
    return np.all(np.isclose(actual, desired, equal_nan=True, **kwargs))
github shoyer / numbagg / numbagg / tests.py View on Github external
funcs_reference_funcs = {
    numbagg.allnan: lambda x, **kwargs: np.all(np.isnan(x), **kwargs),
    numbagg.anynan: lambda x, **kwargs: np.any(np.isnan(x), **kwargs),
    numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
    numbagg.move_nanmean: wrap_pure_python(numbagg.move_nanmean.func),
}


def allclose(actual, desired, **kwargs):
    if getattr(actual, 'shape', ()) != getattr(desired, 'shape', ()):
        return False
    return np.all(np.isclose(actual, desired, equal_nan=True, **kwargs))


def check_func(numbagg_func, ref_func, x, axis):
    actual = numbagg_func(x, axis=axis)
github shoyer / numbagg / numbagg / tests.py View on Github external
funcs_reference_funcs = {
    numbagg.allnan: lambda x, **kwargs: np.all(np.isnan(x), **kwargs),
    numbagg.anynan: lambda x, **kwargs: np.any(np.isnan(x), **kwargs),
    numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
    numbagg.move_nanmean: wrap_pure_python(numbagg.move_nanmean.func),
}


def allclose(actual, desired, **kwargs):
    if getattr(actual, 'shape', ()) != getattr(desired, 'shape', ()):
        return False
    return np.all(np.isclose(actual, desired, equal_nan=True, **kwargs))


def check_func(numbagg_func, ref_func, x, axis):
    actual = numbagg_func(x, axis=axis)
    desired = ref_func(x, axis=axis)
github shoyer / numbagg / numbagg / tests.py View on Github external
def wrapper(x, *args, **kwargs):
        kwargs.pop('axis', None)
        out = np.empty_like(x)
        func(x, *args, out=out, **kwargs)
        return out
    return wrapper


funcs_reference_funcs = {
    numbagg.allnan: lambda x, **kwargs: np.all(np.isnan(x), **kwargs),
    numbagg.anynan: lambda x, **kwargs: np.any(np.isnan(x), **kwargs),
    numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
    numbagg.move_nanmean: wrap_pure_python(numbagg.move_nanmean.func),
}


def allclose(actual, desired, **kwargs):
    if getattr(actual, 'shape', ()) != getattr(desired, 'shape', ()):
github shoyer / numbagg / numbagg / tests.py View on Github external
def wrap_pure_python(func):
    def wrapper(x, *args, **kwargs):
        kwargs.pop('axis', None)
        out = np.empty_like(x)
        func(x, *args, out=out, **kwargs)
        return out
    return wrapper


funcs_reference_funcs = {
    numbagg.allnan: lambda x, **kwargs: np.all(np.isnan(x), **kwargs),
    numbagg.anynan: lambda x, **kwargs: np.any(np.isnan(x), **kwargs),
    numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
    numbagg.move_nanmean: wrap_pure_python(numbagg.move_nanmean.func),
}
github shoyer / numbagg / numbagg / tests.py View on Github external
kwargs.pop('axis', None)
        out = np.empty_like(x)
        func(x, *args, out=out, **kwargs)
        return out
    return wrapper


funcs_reference_funcs = {
    numbagg.allnan: lambda x, **kwargs: np.all(np.isnan(x), **kwargs),
    numbagg.anynan: lambda x, **kwargs: np.any(np.isnan(x), **kwargs),
    numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
    numbagg.move_nanmean: wrap_pure_python(numbagg.move_nanmean.func),
}


def allclose(actual, desired, **kwargs):
    if getattr(actual, 'shape', ()) != getattr(desired, 'shape', ()):
        return False
github shoyer / numbagg / numbagg / tests.py View on Github external
def wrap_pure_python(func):
    def wrapper(x, *args, **kwargs):
        kwargs.pop('axis', None)
        out = np.empty_like(x)
        func(x, *args, out=out, **kwargs)
        return out
    return wrapper


funcs_reference_funcs = {
    numbagg.allnan: lambda x, **kwargs: np.all(np.isnan(x), **kwargs),
    numbagg.anynan: lambda x, **kwargs: np.any(np.isnan(x), **kwargs),
    numbagg.nansum: np.nansum,
    numbagg.nanmean: np.nanmean,
    numbagg.nanstd: np.nanstd,
    numbagg.nanvar: np.nanvar,
    numbagg.nanmax: np.nanmax,
    numbagg.nanmin: np.nanmin,
    numbagg.count: lambda x, **kwargs: np.sum(~np.isnan(x), **kwargs),
}

argmax_reference_funcs = {
    numbagg.nanargmax: np.nanargmax,
    numbagg.nanargmin: np.nanargmin,
}

moving_references_funcs = {
    numbagg.move_nanmean: wrap_pure_python(numbagg.move_nanmean.func),
}