# Path: pyphi/constants.py
# EPSILON = None
# FILESYSTEM = "fs"
# DATABASE = "db"
# PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL
# OFF = (0,)
# ON = (1,)
# 
# Path: pyphi/utils.py
# def state_of(nodes, network_state):
# def all_states(n, big_endian=False):
# def np_immutable(a):
# def np_hash(a):
#     def __init__(self, array):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __repr__(self):
# def eq(x, y):
# def combs(a, r):
# def comb_indices(n, k):
# def powerset(iterable, nonempty=False, reverse=False):
# def load_data(directory, num):
#     def get_path(i):  # pylint: disable=missing-docstring
# def time_annotated(func, *args, **kwargs):
# class np_hashable:


from unittest.mock import patch
from pyphi import constants, utils
import numpy as np

def test_combs_r_is_0():
    n, k = 3, 0
    data = np.arange(n)
    assert np.array_equal(utils.combs(data, k), np.asarray([]))


def test_comb_indices():
    n, k = 3, 2
    data = np.arange(6).reshape(2, 3)
    # fmt: off
    answer = np.array([
        [[0, 1],
         [0, 2],
         [1, 2]],
        [[3, 4],
         [3, 5],
         [4, 5]],
    ])
    # fmt: on
    assert np.array_equal(data[:, utils.comb_indices(n, k)], answer)


def test_powerset():
    a = np.arange(2)
    assert list(utils.powerset(a)) == [(), (0,), (1,), (0, 1)]


def test_powerset_takes_iterable():
    a = iter([0, 1])

# Path: pyphi/constants.py
# EPSILON = None
# FILESYSTEM = "fs"
# DATABASE = "db"
# PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL
# OFF = (0,)
# ON = (1,)
# 
# Path: pyphi/utils.py
# def state_of(nodes, network_state):
# def all_states(n, big_endian=False):
# def np_immutable(a):
# def np_hash(a):
#     def __init__(self, array):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __repr__(self):
# def eq(x, y):
# def combs(a, r):
# def comb_indices(n, k):
# def powerset(iterable, nonempty=False, reverse=False):
# def load_data(directory, num):
#     def get_path(i):  # pylint: disable=missing-docstring
# def time_annotated(func, *args, **kwargs):
# class np_hashable:


# Path: test/test_utils.py
from unittest.mock import patch
from pyphi import constants, utils
import numpy as np


def test_combs_r_is_0():
    n, k = 3, 0
    data = np.arange(n)
    assert np.array_equal(utils.combs(data, k), np.asarray([]))


def test_comb_indices():
    n, k = 3, 2
    data = np.arange(6).reshape(2, 3)
    # fmt: off
    answer = np.array([
        [[0, 1],
         [0, 2],
         [1, 2]],
        [[3, 4],
         [3, 5],
         [4, 5]],
    ])
    # fmt: on
    assert np.array_equal(data[:, utils.comb_indices(n, k)], answer)


def test_powerset():
    a = np.arange(2)
    assert list(utils.powerset(a)) == [(), (0,), (1,), (0, 1)]


def test_powerset_takes_iterable():
    a = iter([0, 1])

    assert list(utils.powerset(a)) == [(), (0,), (1,), (0, 1)]