def _(data: Bag, fr: float, to: float, bins: int) -> Tuple[ndarray, ndarray]: # @jit(nopython=True, nogil=True) # todo: jit this function def inc(values: Iterable[float]) -> ndarray: binned = digitize(values, linspace(fr, to, bins + 1)) init = zeros(bins + 2, dtype=uint64) for i in binned: init[i] += 1 return init hist = data.reduction(inc, sum) return hist, linspace(fr, to, bins + 1)
def _(data: Bag, xfr: float, xto: float, xbins: int, yfr: float, yto: float, ybins: int) -> Tuple[ndarray, ndarray, ndarray]: # @jit(nopython=True, nogil=True) # todo: jit this function def inc(values: Iterable[Tuple[float, float]]) -> ndarray: xvalues, yvalues = column_stack(values) xbinned = digitize(xvalues, linspace(xfr, xto, xbins + 1)) ybinned = digitize(yvalues, linspace(yfr, yto, ybins + 1)) init = zeros((xbins + 2, ybins + 2), dtype=uint64) for x, y in zip(xbinned, ybinned): init[x, y] += 1 return init hist = data.reduction(inc, sum) return hist, linspace(xfr, xto, xbins + 1), linspace(yfr, yto, ybins + 1)