# Path: tensorprob/utilities.py
# NAME_COUNTERS = defaultdict(lambda: 0)
# def generate_name(obj):
#     def __init__(self, getter):
#     def __get__(self, instance, owner):
# def grouper(iterable, n=2, fillvalue=None):
# def flatten(l):
# def is_finite(obj):
# def pairwise(iterable):
# def set_logp_to_neg_inf(X, logp, bounds):
# def find_common_bounds(bounds_1, bounds_2):
# class classproperty(object):


from tensorprob import utilities


def test_generate_name():
    class SomeTestClass(object):
        pass

    def some_test_function():
        pass

    assert utilities.generate_name(SomeTestClass) == 'SomeTestClass_1'
    assert utilities.generate_name(some_test_function) == 'some_test_function_1'
    assert utilities.generate_name(SomeTestClass) == 'SomeTestClass_2'
    assert utilities.generate_name(some_test_function) == 'some_test_function_2'
    assert utilities.generate_name(some_test_function) == 'some_test_function_3'


def test_class_property():
    class SomeTestClass(object):
        @utilities.classproperty
        def new_class_property(cls):
            return cls, 'test_string'

    assert SomeTestClass.new_class_property == (SomeTestClass, 'test_string')


def test_grouper():

# Path: tensorprob/utilities.py
# NAME_COUNTERS = defaultdict(lambda: 0)
# def generate_name(obj):
#     def __init__(self, getter):
#     def __get__(self, instance, owner):
# def grouper(iterable, n=2, fillvalue=None):
# def flatten(l):
# def is_finite(obj):
# def pairwise(iterable):
# def set_logp_to_neg_inf(X, logp, bounds):
# def find_common_bounds(bounds_1, bounds_2):
# class classproperty(object):


# Path: tests/test_utilities.py
from tensorprob import utilities



def test_generate_name():
    class SomeTestClass(object):
        pass

    def some_test_function():
        pass

    assert utilities.generate_name(SomeTestClass) == 'SomeTestClass_1'
    assert utilities.generate_name(some_test_function) == 'some_test_function_1'
    assert utilities.generate_name(SomeTestClass) == 'SomeTestClass_2'
    assert utilities.generate_name(some_test_function) == 'some_test_function_2'
    assert utilities.generate_name(some_test_function) == 'some_test_function_3'


def test_class_property():
    class SomeTestClass(object):
        @utilities.classproperty
        def new_class_property(cls):
            return cls, 'test_string'

    assert SomeTestClass.new_class_property == (SomeTestClass, 'test_string')


def test_grouper():

    grouped = utilities.grouper([0, 1, 2, 3, 4], n=2)