<commit_before>"""

>>> from blaze.expr.table import TableSymbol
>>> from blaze.compute.python import compute

>>> accounts = TableSymbol('{name: string, amount: int}')
>>> deadbeats = accounts['name'][accounts['amount'] < 0]

>>> data = [['Alice', 100], ['Bob', -50], ['Charlie', -20]]
>>> list(compute(deadbeats, data))
['Bob', 'Charlie']
"""
from __future__ import absolute_import, division, print_function

from blaze.expr.table import *
from blaze.compatibility import builtins
from blaze.utils import groupby, get
from multipledispatch import dispatch
import itertools
from collections import Iterator
import math
from ..utils import reduceby

seq = (tuple, list, Iterator)

@dispatch(Projection, seq)
def compute(t, l):
    parent = compute(t.parent, l)
    indices = [t.parent.columns.index(col) for col in t.columns]
    get = operator.itemgetter(*indices)
    return (get(x) for x in parent)


@dispatch(Column, seq)
def compute(t, l):
    parent = compute(t.parent, l)
    index = t.parent.columns.index(t.columns[0])
    return (x[index] for x in parent)


@dispatch(BinOp, seq)
def compute(t, l):
    lhs_istable = isinstance(t.lhs, TableExpr)
    rhs_istable = isinstance(t.rhs, TableExpr)

    if lhs_istable and rhs_istable:

        l1, l2 = itertools.tee(l, 2)
        lhs = compute(t.lhs, l1)
        rhs = compute(t.rhs, l2)

        return (t.op(left, right) for left, right in zip(lhs, rhs))
<commit_msg>fix imports in compute python<commit_after>"""

>>> from blaze.expr.table import TableSymbol
>>> from blaze.compute.python import compute

>>> accounts = TableSymbol('{name: string, amount: int}')
>>> deadbeats = accounts['name'][accounts['amount'] < 0]

>>> data = [['Alice', 100], ['Bob', -50], ['Charlie', -20]]
>>> list(compute(deadbeats, data))
['Bob', 'Charlie']
"""
from __future__ import absolute_import, division, print_function

from multipledispatch import dispatch
import itertools
from collections import Iterator
import math

from ..expr.table import *
from ..compatibility import builtins
from ..utils import groupby, get, reduceby

seq = (tuple, list, Iterator)

@dispatch(Projection, seq)
def compute(t, l):
    parent = compute(t.parent, l)
    indices = [t.parent.columns.index(col) for col in t.columns]
    get = operator.itemgetter(*indices)
    return (get(x) for x in parent)


@dispatch(Column, seq)
def compute(t, l):
    parent = compute(t.parent, l)
    index = t.parent.columns.index(t.columns[0])
    return (x[index] for x in parent)


@dispatch(BinOp, seq)
def compute(t, l):
    lhs_istable = isinstance(t.lhs, TableExpr)
    rhs_istable = isinstance(t.rhs, TableExpr)

    if lhs_istable and rhs_istable:

        l1, l2 = itertools.tee(l, 2)
        lhs = compute(t.lhs, l1)
        rhs = compute(t.rhs, l2)

        return (t.op(left, right) for left, right in zip(lhs, rhs))

{'fraction_non_alphanumeric': 0.14446793516560957, 'fraction_numerical': 0.009866102889358703, 'mean_word_length': 4.124548736462094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3064129', 'n_tokens_mistral': 980, 'n_tokens_neox': 957, 'n_words': 277}