# Path: loom/util.py
# @contextlib.contextmanager
# def tempdir(cleanup_on_error=True):
#     oldwd = os.getcwd()
#     wd = tempfile.mkdtemp()
#     try:
#         os.chdir(wd)
#         yield wd
#         cleanup_on_error = True
#     finally:
#         os.chdir(oldwd)
#         if cleanup_on_error:
#             shutil.rmtree(wd)


import os
import sys
import numpy
import numpy.random
import loom.schema_pb2
import loom.schema
import loom.format
import loom.runner
import loom.util
import loom.test.util
import parsable
from itertools import imap, product
from nose import SkipTest
from nose.tools import assert_true, assert_false, assert_equal
from distributions.tests.util import seed_all
from distributions.util import scores_to_probs
from distributions.io.stream import protobuf_stream_load, protobuf_stream_dump
from distributions.lp.clustering import PitmanYor
from distributions.util import multinomial_goodness_of_fit
from loom.util import tempdir
    errors = sum(parallel_map(_test_dataset, datasets), [])
    message = '\n'.join(['Failed {} Cases:'.format(len(errors))] + errors)
    assert_false(errors, message)


# Run tiny examples through nose and expensive examples by hand.

def test_cat_inference():
    infer_cats(100)


def test_kind_inference():
    infer_kinds(50)


def test_feature_hyper_inference():
    infer_feature_hypers(100)


def test_topology_hyper_inference():
    infer_topology_hypers(50)


def test_clustering_hyper_inference():
    infer_clustering_hypers(100)


def _test_dataset(args):
    dim, feature_type, density, infer_kinds, debug, hyper_prior = args
    object_count, feature_count = dim

# Path: loom/util.py
# @contextlib.contextmanager
# def tempdir(cleanup_on_error=True):
#     oldwd = os.getcwd()
#     wd = tempfile.mkdtemp()
#     try:
#         os.chdir(wd)
#         yield wd
#         cleanup_on_error = True
#     finally:
#         os.chdir(oldwd)
#         if cleanup_on_error:
#             shutil.rmtree(wd)


# Path: loom/test/test_posterior_enum.py
import os
import sys
import numpy
import numpy.random
import loom.schema_pb2
import loom.schema
import loom.format
import loom.runner
import loom.util
import loom.test.util
import parsable
from itertools import imap, product
from nose import SkipTest
from nose.tools import assert_true, assert_false, assert_equal
from distributions.tests.util import seed_all
from distributions.util import scores_to_probs
from distributions.io.stream import protobuf_stream_load, protobuf_stream_dump
from distributions.lp.clustering import PitmanYor
from distributions.util import multinomial_goodness_of_fit
from loom.util import tempdir

    errors = sum(parallel_map(_test_dataset, datasets), [])
    message = '\n'.join(['Failed {} Cases:'.format(len(errors))] + errors)
    assert_false(errors, message)


# Run tiny examples through nose and expensive examples by hand.

def test_cat_inference():
    infer_cats(100)


def test_kind_inference():
    infer_kinds(50)


def test_feature_hyper_inference():
    infer_feature_hypers(100)


def test_topology_hyper_inference():
    infer_topology_hypers(50)


def test_clustering_hyper_inference():
    infer_clustering_hypers(100)


def _test_dataset(args):
    dim, feature_type, density, infer_kinds, debug, hyper_prior = args
    object_count, feature_count = dim

    with tempdir(cleanup_on_error=(not debug)):