# Path: telluride_decoding/attention_decoder.py
# def plot_aad_results(decision, attention_flag=None,
#                      decision_upper=None, decision_lower=None,
#                      t=None, xlabel='Time (frames)',
#                      ylabel='Prob of Speaker 1',
#                      title='AAD Decoding Result',
#                      linecolor='blue'):
#   def attention(self, r1, r2):
#   def tune(self, r1, r2):
#   def __init__(self):
#   def attention(self, r1, r2):
#   def __init__(self, outer_iter, inner_iter, newton_iter, fs_corr,
#                forward_lag=0, backward_lag=13, offset=0.0):
#   def tune(self, r1, r2):
#   def tune_log_normal_priors(self, r1, r2):
#   def attention(self, r1, r2):
# def create_attention_decoder(type_name, window_step=100, frame_rate=100.0,
#                              ssd_offset=0.0):
# class AttentionDecoder(object):
# class StepAttentionDecoder(AttentionDecoder):
# class StateSpaceAttentionDecoder(AttentionDecoder):


from absl.testing import absltest
from absl.testing import parameterized
from telluride_decoding import attention_decoder
import matplotlib.axes as axes
import matplotlib.pyplot as plt
import mock
import numpy as np
    # values that are used to make a single attentional state decision so the
    # first decoded attentional state corresponds to the 100+ad.k_w true_state
    # (this is a bit complicated when using forward lags because the first
    # decoded attentional state would correspond to the 100+ad.k_w-ad.k_f th
    # true_state).

    # The true_state vector is a vector of 1s and 2s corresponding to the labels
    # speaker 1 and speaker 2, so we convert to a boolean where True indicates
    # attending to speaker 1 and False to attending to speaker 2.
    error = np.mean(np.abs(s1 != (true_state[init_frames+ad.k_w:] < 2)))
    self.assertLess(error, 0.15)

  def test_log_normal_initialization(self):
    # Pick two different sets of parameters and make sure the initialization
    # code recovers the correct Gaussian parameters

    # Number of observations
    num_data = 1000000

    # Generate attended speaker data (log-normal)
    mu_a = 0.2
    var_a = 0.1
    data_a = np.exp(np.random.randn(num_data)*var_a + mu_a)

    # Generate unattended speaker data (log-normal)
    mu_b = 0.0
    var_b = 0.1
    data_b = np.exp(np.random.randn(num_data)*var_b + mu_b)

    # Create attention decoder object

# Path: telluride_decoding/attention_decoder.py
# def plot_aad_results(decision, attention_flag=None,
#                      decision_upper=None, decision_lower=None,
#                      t=None, xlabel='Time (frames)',
#                      ylabel='Prob of Speaker 1',
#                      title='AAD Decoding Result',
#                      linecolor='blue'):
#   def attention(self, r1, r2):
#   def tune(self, r1, r2):
#   def __init__(self):
#   def attention(self, r1, r2):
#   def __init__(self, outer_iter, inner_iter, newton_iter, fs_corr,
#                forward_lag=0, backward_lag=13, offset=0.0):
#   def tune(self, r1, r2):
#   def tune_log_normal_priors(self, r1, r2):
#   def attention(self, r1, r2):
# def create_attention_decoder(type_name, window_step=100, frame_rate=100.0,
#                              ssd_offset=0.0):
# class AttentionDecoder(object):
# class StepAttentionDecoder(AttentionDecoder):
# class StateSpaceAttentionDecoder(AttentionDecoder):


# Path: test/attention_decoder_test.py
from absl.testing import absltest
from absl.testing import parameterized
from telluride_decoding import attention_decoder
import matplotlib.axes as axes
import matplotlib.pyplot as plt
import mock
import numpy as np

    # values that are used to make a single attentional state decision so the
    # first decoded attentional state corresponds to the 100+ad.k_w true_state
    # (this is a bit complicated when using forward lags because the first
    # decoded attentional state would correspond to the 100+ad.k_w-ad.k_f th
    # true_state).

    # The true_state vector is a vector of 1s and 2s corresponding to the labels
    # speaker 1 and speaker 2, so we convert to a boolean where True indicates
    # attending to speaker 1 and False to attending to speaker 2.
    error = np.mean(np.abs(s1 != (true_state[init_frames+ad.k_w:] < 2)))
    self.assertLess(error, 0.15)

  def test_log_normal_initialization(self):
    # Pick two different sets of parameters and make sure the initialization
    # code recovers the correct Gaussian parameters

    # Number of observations
    num_data = 1000000

    # Generate attended speaker data (log-normal)
    mu_a = 0.2
    var_a = 0.1
    data_a = np.exp(np.random.randn(num_data)*var_a + mu_a)

    # Generate unattended speaker data (log-normal)
    mu_b = 0.0
    var_b = 0.1
    data_b = np.exp(np.random.randn(num_data)*var_b + mu_b)

    # Create attention decoder object

    ad = attention_decoder.StateSpaceAttentionDecoder(20, 1, 10, 1, 1)