# Path: idtxl/idtxl_utils.py
# def calculate_mi(corr):
#     """Calculate mutual information from correlation coefficient."""
#     return -0.5 * np.log(1 - corr**2)


import pytest
import random as rn
import numpy as np
import idtxl.idtxl_exceptions as ex
    import jpype
from scipy.special import digamma
from idtxl.estimators_jidt import (JidtKraskovCMI, JidtKraskovMI,
                                   JidtKraskovAIS, JidtKraskovTE,
                                   JidtDiscreteCMI, JidtDiscreteMI,
                                   JidtDiscreteAIS, JidtDiscreteTE,
                                   JidtGaussianCMI, JidtGaussianMI,
                                   JidtGaussianAIS, JidtGaussianTE)
from idtxl.idtxl_utils import calculate_mi
        reason="Jpype is missing, JIDT estimators are not available")

SEED = 0


def _assert_result(results, expected_res, estimator, measure, tol=0.05):
    # Compare estimates with analytic results and print output.
    print('{0} - {1} result: {2:.4f} nats expected to be close to {3:.4f} '
          'nats.'.format(estimator, measure, results, expected_res))
    assert np.isclose(results, expected_res, atol=tol), (
        '{0} calculation failed (error larger than {1}).'.format(measure, tol))


def _compare_result(res1, res2, estimator1, estimator2, measure, tol=0.05):
    # Compare estimates with each other and print output.
    print('{0} vs. {1} - {2} result: {3:.4f} nats vs. {4:.4f} '
          'nats.'.format(estimator1, estimator2, measure, res1, res2))
    assert np.isclose(res1, res2, atol=tol), (
                        '{0} calculation failed (error larger than '
                        '{1}).'.format(measure, tol))


def _get_gauss_data(n=10000, covariance=0.4, expand=True, seed=None):
    """Generate correlated and uncorrelated Gaussian variables.

    Generate two sets of random normal data, where one set has a given
    covariance and the second is uncorrelated.
    """
    np.random.seed(seed)
    corr_expected = covariance / (1 * np.sqrt(covariance**2 + (1-covariance)**2))

# Path: idtxl/idtxl_utils.py
# def calculate_mi(corr):
#     """Calculate mutual information from correlation coefficient."""
#     return -0.5 * np.log(1 - corr**2)


# Path: test/test_estimators_jidt.py
import pytest
import random as rn
import numpy as np
import idtxl.idtxl_exceptions as ex
    import jpype
from scipy.special import digamma
from idtxl.estimators_jidt import (JidtKraskovCMI, JidtKraskovMI,
                                   JidtKraskovAIS, JidtKraskovTE,
                                   JidtDiscreteCMI, JidtDiscreteMI,
                                   JidtDiscreteAIS, JidtDiscreteTE,
                                   JidtGaussianCMI, JidtGaussianMI,
                                   JidtGaussianAIS, JidtGaussianTE)
from idtxl.idtxl_utils import calculate_mi

        reason="Jpype is missing, JIDT estimators are not available")

SEED = 0


def _assert_result(results, expected_res, estimator, measure, tol=0.05):
    # Compare estimates with analytic results and print output.
    print('{0} - {1} result: {2:.4f} nats expected to be close to {3:.4f} '
          'nats.'.format(estimator, measure, results, expected_res))
    assert np.isclose(results, expected_res, atol=tol), (
        '{0} calculation failed (error larger than {1}).'.format(measure, tol))


def _compare_result(res1, res2, estimator1, estimator2, measure, tol=0.05):
    # Compare estimates with each other and print output.
    print('{0} vs. {1} - {2} result: {3:.4f} nats vs. {4:.4f} '
          'nats.'.format(estimator1, estimator2, measure, res1, res2))
    assert np.isclose(res1, res2, atol=tol), (
                        '{0} calculation failed (error larger than '
                        '{1}).'.format(measure, tol))


def _get_gauss_data(n=10000, covariance=0.4, expand=True, seed=None):
    """Generate correlated and uncorrelated Gaussian variables.

    Generate two sets of random normal data, where one set has a given
    covariance and the second is uncorrelated.
    """
    np.random.seed(seed)
    corr_expected = covariance / (1 * np.sqrt(covariance**2 + (1-covariance)**2))

    expected_mi = calculate_mi(corr_expected)