# Path: pyphi/convert.py
# def reverse_bits(i, n):
# def be2le(i, n):
# def nodes2indices(nodes):
# def nodes2state(nodes):
# def state2be_index(state):
# def state2le_index(state):
# def le_index2state(i, number_of_nodes):
# def be_index2state(i, number_of_nodes):
# def be2le_state_by_state(tpm):
# def to_multidimensional(tpm):
# def to_2dimensional(tpm):
# def state_by_state2state_by_node(tpm):
# def _deterministic_sbn2sbs(Sp, Sn, sbn_tpm):
# def _unfold_nodewise_probabilities(Nn, Sn, sbn_row):
# def _nondeterministic_sbn2sbs(Nn, Sn, sbn_tpm):
# def state_by_node2state_by_state(tpm):
#     N = tpm.shape[0]
#     S = np.prod(tpm.shape[:-1])
#     N = tpm.shape[-1]
#     S = tpm.shape[-1]
#     N = int(log2(S))


from math import log2
from pyphi import convert
import numpy as np

    for tpm in [
        state_by_node,
        twod_state_by_node,
        nonsquare_deterministic_1,
        nonsquare_deterministic_2,
        nonsquare_nondeterministic_1,
        nonsquare_nondeterministic_2,
    ]:
        S = tpm.shape[0]
        N = int(log2(S))
        result = convert.to_multidimensional(tpm)
        for i in range(S):
            state = convert.le_index2state(i, N)
            assert np.array_equal(result[state], tpm[i])


def test_to_2dimensional():
    # Identity
    assert np.array_equal(convert.to_2dimensional(state_by_node), state_by_node)
    # Idempotency
    for tpm in [
        state_by_node,
        state_by_node_nondet,
        twod_state_by_node,
        nonsquare_deterministic_1,
        nonsquare_deterministic_2,
        nonsquare_nondeterministic_1,
        nonsquare_nondeterministic_2,
    ]:

# Path: pyphi/convert.py
# def reverse_bits(i, n):
# def be2le(i, n):
# def nodes2indices(nodes):
# def nodes2state(nodes):
# def state2be_index(state):
# def state2le_index(state):
# def le_index2state(i, number_of_nodes):
# def be_index2state(i, number_of_nodes):
# def be2le_state_by_state(tpm):
# def to_multidimensional(tpm):
# def to_2dimensional(tpm):
# def state_by_state2state_by_node(tpm):
# def _deterministic_sbn2sbs(Sp, Sn, sbn_tpm):
# def _unfold_nodewise_probabilities(Nn, Sn, sbn_row):
# def _nondeterministic_sbn2sbs(Nn, Sn, sbn_tpm):
# def state_by_node2state_by_state(tpm):
#     N = tpm.shape[0]
#     S = np.prod(tpm.shape[:-1])
#     N = tpm.shape[-1]
#     S = tpm.shape[-1]
#     N = int(log2(S))


# Path: test/test_convert.py
from math import log2
from pyphi import convert
import numpy as np


    for tpm in [
        state_by_node,
        twod_state_by_node,
        nonsquare_deterministic_1,
        nonsquare_deterministic_2,
        nonsquare_nondeterministic_1,
        nonsquare_nondeterministic_2,
    ]:
        S = tpm.shape[0]
        N = int(log2(S))
        result = convert.to_multidimensional(tpm)
        for i in range(S):
            state = convert.le_index2state(i, N)
            assert np.array_equal(result[state], tpm[i])


def test_to_2dimensional():
    # Identity
    assert np.array_equal(convert.to_2dimensional(state_by_node), state_by_node)
    # Idempotency
    for tpm in [
        state_by_node,
        state_by_node_nondet,
        twod_state_by_node,
        nonsquare_deterministic_1,
        nonsquare_deterministic_2,
        nonsquare_nondeterministic_1,
        nonsquare_nondeterministic_2,
    ]:

        nd = convert.to_multidimensional(tpm)