<commit_before>"""

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

>>> accounts = TableExpr('{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 multipledispatch import dispatch
import itertools
from collections import Iterator

base = (int, float, str, bool)

seq = (tuple, list, Iterator)

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


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


@dispatch(base, object)
def compute(a, b):
    return a


@dispatch(ColumnWise, 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))

    elif lhs_istable:

        lhs = compute(t.lhs, l)
        right = compute(t.rhs, None)

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

    elif rhs_istable:

        rhs = compute(t.rhs, l)<commit_msg>remove base case from python<commit_after>"""

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

>>> accounts = TableExpr('{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 multipledispatch import dispatch
import itertools
from collections import Iterator

seq = (tuple, list, Iterator)

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


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


@dispatch(ColumnWise, 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))

    elif lhs_istable:

        lhs = compute(t.lhs, l)
        right = compute(t.rhs, None)

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

    elif rhs_istable:

        rhs = compute(t.rhs, l)
{'fraction_non_alphanumeric': 0.14792299898682879, 'fraction_numerical': 0.009456264775413711, 'mean_word_length': 3.6065318818040435, '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': '1168630', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1041, 'n_words': 289}