def split(leaf, expr, chunk=None, agg=None, **kwargs):
    """ Split expression for chunked computation

    Break up a computation ``leaf -> expr`` so that it can be run in chunks.
    This returns two computations, one to perform on each chunk and then one to
    perform on the union of these intermediate results

        chunk -> chunk-expr
        aggregate -> aggregate-expr

    The chunk_expr will have the same dimesions as the input
    (reductions set keepdims=True) so that this should work cleanly with
    concatenation functions like ``np.concatenate``.

    Returns
    -------

    Pair of (Symbol, Expr) pairs

        (chunk, chunk_expr), (aggregate, aggregate_expr)

    >>> t = symbol('t', 'var * {name: string, amount: int, id: int}')
    >>> expr = t.id.count()
    >>> split(t, expr)
    ((<`chunk` symbol; dshape='...'>, count(chunk.id, keepdims=True)), (<`aggregate` symbol; dshape='...'>, sum(aggregate)))
    """
    center = path_split(leaf, expr)
    if chunk is None:
        if 1 > leaf.ndim:
            raise ValueError("Please provide a chunk symbol")
        else:
            chunk = symbol('chunk', datashape.var * leaf.dshape.measure)

    chunk_expr = _split_chunk(center, leaf=leaf, chunk=chunk, **kwargs)
    chunk_expr_with_keepdims = _split_chunk(center, leaf=leaf, chunk=chunk,
                                            keepdims=True)

    if agg is None:
        agg_shape = aggregate_shape(leaf, expr, chunk, chunk_expr_with_keepdims)
        agg_dshape = DataShape(*(agg_shape + (chunk_expr.dshape.measure,)))
        agg = symbol('aggregate', agg_dshape)

    agg_expr = _split_agg(center, leaf=leaf, agg=agg)

    return ((chunk, chunk_expr),
            (agg, expr._subs({center: agg})._subs({agg: agg_expr})))
dataset/ETHPy150Open blaze/blaze/blaze/expr/split.py/split/swapped operands of `>`