def conditionally_independent(tpm):
    """Validate that the TPM is conditionally independent."""
    if not config.VALIDATE_CONDITIONAL_INDEPENDENCE:
        return True
    tpm = np.array(tpm)
    if is_state_by_state(tpm):
        there_and_back_again = convert.state_by_node2state_by_state(
            convert.state_by_state2state_by_node(tpm))
    else:
        there_and_back_again = convert.state_by_state2state_by_node(
            convert.state_by_node2state_by_state(tpm))
    if np.any((tpm - there_and_back_again) >= EPSILON):
        raise exceptions.ConditionallyDependentError(
            'TPM is not conditionally independent.\n'
            'See the conditional independence example in the documentation '
            'for more info.')
    return True
def conditionally_independent ( tpm ) : if not config . VALIDATE_CONDITIONAL_INDEPENDENCE : return True tpm = np . array ( tpm ) if is_state_by_state ( tpm ) : there_and_back_again = convert . state_by_node2state_by_state ( convert . state_by_state2state_by_node ( tpm ) ) else : there_and_back_again = convert . state_by_state2state_by_node ( convert . state_by_node2state_by_state ( tpm ) ) if np . any ( ( tpm - there_and_back_again ) >= EPSILON ) : raise exceptions . ConditionallyDependentError ( 'TPM is not conditionally independent.\n' 'See the conditional independence example in the documentation ' 'for more info.' ) return True
Validate that the TPM is conditionally independent.