# Path: pyphi/tpm.py
# def is_deterministic(tpm):
#     """Return whether the TPM is deterministic."""
#     return np.all(np.logical_or(tpm == 1, tpm == 0))


import logging
import numpy as np
from itertools import product
from math import log2
from .tpm import is_deterministic
           [0., 0., 0., 0., 1., 0., 0., 0.],
           [0., 1., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 1.],
           [0., 0., 0., 0., 0., 1., 0., 0.]])
    >>> tpm = np.array([[0.1, 0.3, 0.7],
    ...                 [0.3, 0.9, 0.2],
    ...                 [0.3, 0.9, 0.1],
    ...                 [0.2, 0.8, 0.5],
    ...                 [0.1, 0.7, 0.4],
    ...                 [0.4, 0.3, 0.6],
    ...                 [0.4, 0.3, 0.1],
    ...                 [0.5, 0.2, 0.1]])
    >>> state_by_node2state_by_state(tpm)
    array([[0.189, 0.021, 0.081, 0.009, 0.441, 0.049, 0.189, 0.021],
           [0.056, 0.024, 0.504, 0.216, 0.014, 0.006, 0.126, 0.054],
           [0.063, 0.027, 0.567, 0.243, 0.007, 0.003, 0.063, 0.027],
           [0.08 , 0.02 , 0.32 , 0.08 , 0.08 , 0.02 , 0.32 , 0.08 ],
           [0.162, 0.018, 0.378, 0.042, 0.108, 0.012, 0.252, 0.028],
           [0.168, 0.112, 0.072, 0.048, 0.252, 0.168, 0.108, 0.072],
           [0.378, 0.252, 0.162, 0.108, 0.042, 0.028, 0.018, 0.012],
           [0.36 , 0.36 , 0.09 , 0.09 , 0.04 , 0.04 , 0.01 , 0.01 ]])
    """
    # Reshape to 2D
    sbn_tpm = to_2dimensional(tpm)
    # Get number of previous states
    Sp = sbn_tpm.shape[0]
    # Get number of nodes in the next state
    Nn = sbn_tpm.shape[1]
    # Get the number of next states
    Sn = 2 ** Nn

# Path: pyphi/tpm.py
# def is_deterministic(tpm):
#     """Return whether the TPM is deterministic."""
#     return np.all(np.logical_or(tpm == 1, tpm == 0))


# Path: pyphi/convert.py
import logging
import numpy as np
from itertools import product
from math import log2
from .tpm import is_deterministic

           [0., 0., 0., 0., 1., 0., 0., 0.],
           [0., 1., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 1.],
           [0., 0., 0., 0., 0., 1., 0., 0.]])
    >>> tpm = np.array([[0.1, 0.3, 0.7],
    ...                 [0.3, 0.9, 0.2],
    ...                 [0.3, 0.9, 0.1],
    ...                 [0.2, 0.8, 0.5],
    ...                 [0.1, 0.7, 0.4],
    ...                 [0.4, 0.3, 0.6],
    ...                 [0.4, 0.3, 0.1],
    ...                 [0.5, 0.2, 0.1]])
    >>> state_by_node2state_by_state(tpm)
    array([[0.189, 0.021, 0.081, 0.009, 0.441, 0.049, 0.189, 0.021],
           [0.056, 0.024, 0.504, 0.216, 0.014, 0.006, 0.126, 0.054],
           [0.063, 0.027, 0.567, 0.243, 0.007, 0.003, 0.063, 0.027],
           [0.08 , 0.02 , 0.32 , 0.08 , 0.08 , 0.02 , 0.32 , 0.08 ],
           [0.162, 0.018, 0.378, 0.042, 0.108, 0.012, 0.252, 0.028],
           [0.168, 0.112, 0.072, 0.048, 0.252, 0.168, 0.108, 0.072],
           [0.378, 0.252, 0.162, 0.108, 0.042, 0.028, 0.018, 0.012],
           [0.36 , 0.36 , 0.09 , 0.09 , 0.04 , 0.04 , 0.01 , 0.01 ]])
    """
    # Reshape to 2D
    sbn_tpm = to_2dimensional(tpm)
    # Get number of previous states
    Sp = sbn_tpm.shape[0]
    # Get number of nodes in the next state
    Nn = sbn_tpm.shape[1]
    # Get the number of next states
    Sn = 2 ** Nn

    if is_deterministic(tpm):