# Path: loom/format.py
# def load_decoder(encoder):
#     model = encoder['model']
#     if 'symbols' in encoder:
#         decoder = {value: key for key, value in encoder['symbols'].iteritems()}
#         decode = decoder.__getitem__
#     elif model == 'bb':
#         decode = ('0', '1').__getitem__
#     else:
#         decode = str
#     return decode
# 
# Path: loom/format.py
# def load_encoder(encoder):
#     model = encoder['model']
#     if 'symbols' in encoder:
#         encode = encoder['symbols'].__getitem__
#     elif model == 'bb':
#         encode = BOOLEAN_SYMBOLS.__getitem__
#     else:
#         encode = loom.schema.MODELS[model].Value
#     return encode


from copy import copy
from contextlib import contextmanager
from itertools import izip
from collections import Counter
from distributions.io.stream import json_load
from distributions.io.stream import open_compressed
from StringIO import StringIO
from sklearn.cluster import SpectralClustering
from loom.format import load_decoder
from loom.format import load_encoder
import csv
import math
import numpy
import loom.store
import loom.query
import loom.group
        support(target_feature_sets, known_feature_sets, conditioning_row, ...)
            Determine which knolwedge has informed target features, in context.

        group(column, result_out)
            Cluster rows according to target column and related columns.

    Properties:

        feature_names - a list of all feature names
        converters - a dict of converters for use in pandas.read_csv
    '''
    def __init__(self, query_server, encoding=None, debug=False):
        self._paths = loom.store.get_paths(query_server.root)
        if encoding is None:
            encoding = self._paths['ingest']['encoding']
        self._query_server = query_server
        self._encoders = json_load(encoding)
        transforms = self._paths['ingest']['transforms']
        self._transform = loom.transforms.load_transforms(transforms)
        self._feature_names = [e['name'] for e in self._encoders]
        self._feature_set = frozenset(self._feature_names)
        self._name_to_pos = {
            name: i
            for i, name in enumerate(self._feature_names)
        }
        self._name_to_decode = {
            e['name']: load_decoder(e)
            for e in self._encoders
        }
        self._name_to_encode = {

# Path: loom/format.py
# def load_decoder(encoder):
#     model = encoder['model']
#     if 'symbols' in encoder:
#         decoder = {value: key for key, value in encoder['symbols'].iteritems()}
#         decode = decoder.__getitem__
#     elif model == 'bb':
#         decode = ('0', '1').__getitem__
#     else:
#         decode = str
#     return decode
# 
# Path: loom/format.py
# def load_encoder(encoder):
#     model = encoder['model']
#     if 'symbols' in encoder:
#         encode = encoder['symbols'].__getitem__
#     elif model == 'bb':
#         encode = BOOLEAN_SYMBOLS.__getitem__
#     else:
#         encode = loom.schema.MODELS[model].Value
#     return encode


# Path: loom/preql.py
from copy import copy
from contextlib import contextmanager
from itertools import izip
from collections import Counter
from distributions.io.stream import json_load
from distributions.io.stream import open_compressed
from StringIO import StringIO
from sklearn.cluster import SpectralClustering
from loom.format import load_decoder
from loom.format import load_encoder
import csv
import math
import numpy
import loom.store
import loom.query
import loom.group

        support(target_feature_sets, known_feature_sets, conditioning_row, ...)
            Determine which knolwedge has informed target features, in context.

        group(column, result_out)
            Cluster rows according to target column and related columns.

    Properties:

        feature_names - a list of all feature names
        converters - a dict of converters for use in pandas.read_csv
    '''
    def __init__(self, query_server, encoding=None, debug=False):
        self._paths = loom.store.get_paths(query_server.root)
        if encoding is None:
            encoding = self._paths['ingest']['encoding']
        self._query_server = query_server
        self._encoders = json_load(encoding)
        transforms = self._paths['ingest']['transforms']
        self._transform = loom.transforms.load_transforms(transforms)
        self._feature_names = [e['name'] for e in self._encoders]
        self._feature_set = frozenset(self._feature_names)
        self._name_to_pos = {
            name: i
            for i, name in enumerate(self._feature_names)
        }
        self._name_to_decode = {
            e['name']: load_decoder(e)
            for e in self._encoders
        }
        self._name_to_encode = {

            e['name']: load_encoder(e)