# Path: telluride_decoding/utils.py
# def pearson_correlation_graph(x, y):
#   def t(x):


import numpy as np
import tensorflow.compat.v2 as tf
from telluride_decoding import utils
    # Example data from: http://www.statisticshowto.com/
    #       probability-and-statistics/correlation-coefficient-formula/
    correlation_data = np.array([
        [1, 43, 99],
        [2, 21, 65],
        [3, 25, 79],
        [4, 42, 75],
        [5, 57, 87],
        [6, 59, 81]], dtype=np.float32)
    # Test the correlation graph using the sample data above
    test_x = correlation_data[:, 1]
    test_y = correlation_data[:, 2]
    correlation_tensor = utils.pearson_correlation_graph(test_x, test_y)

    correlation_r = correlation_tensor.numpy()
    print('Test_pearson produced:', correlation_r)
    np.testing.assert_allclose(np.asarray([[1, .5298],
                                           [.5298, 1]]), correlation_r,
                               atol=0.0001)

  def test_pearson2(self):
    """Test to make sure TF and np.corrcoef give same answers with random data.

    This test makes sure it works with multi-dimensional features.
    """
    fsize = 2  # feature size
    dsize = 6  # sample count
    x = np.random.random((dsize, fsize))
    y = np.random.random((dsize, fsize))


# Path: telluride_decoding/utils.py
# def pearson_correlation_graph(x, y):
#   def t(x):


# Path: test/utils_test.py
import numpy as np
import tensorflow.compat.v2 as tf
from telluride_decoding import utils

    # Example data from: http://www.statisticshowto.com/
    #       probability-and-statistics/correlation-coefficient-formula/
    correlation_data = np.array([
        [1, 43, 99],
        [2, 21, 65],
        [3, 25, 79],
        [4, 42, 75],
        [5, 57, 87],
        [6, 59, 81]], dtype=np.float32)
    # Test the correlation graph using the sample data above
    test_x = correlation_data[:, 1]
    test_y = correlation_data[:, 2]
    correlation_tensor = utils.pearson_correlation_graph(test_x, test_y)

    correlation_r = correlation_tensor.numpy()
    print('Test_pearson produced:', correlation_r)
    np.testing.assert_allclose(np.asarray([[1, .5298],
                                           [.5298, 1]]), correlation_r,
                               atol=0.0001)

  def test_pearson2(self):
    """Test to make sure TF and np.corrcoef give same answers with random data.

    This test makes sure it works with multi-dimensional features.
    """
    fsize = 2  # feature size
    dsize = 6  # sample count
    x = np.random.random((dsize, fsize))
    y = np.random.random((dsize, fsize))


    cor = utils.pearson_correlation_graph(x, y)