# Path: mjhmc/misc/utils.py
# def min_idx(draws):
#     """
#     selects the argmin of the row wise minimum
#     returns a list of rows where each input draw was min
#     draws: a list of the various draws
# 
#     eg: draws = [fl_draws, f_draws] where fl_draws.shape = f_draws.shape = (1, N)
#     returns fl_idx, f_idx where fl_idx (and the others) are
#     arrays of shape (nbatch,) containing the indices of the rows where each variable was
#     the minimum
#     """
#     cdraws = np.concatenate(draws, axis=0)
#     transition_idx = np.argmin(cdraws, axis=0)
#     return [np.where(transition_idx == i)[0] for i in xrange(len(draws))]


import unittest
import numpy as np
from mjhmc.misc.utils import min_idx

class TestMinIdx(unittest.TestCase):
    """test that min idx works
    """

    def setUp(self):
        np.random.seed(n_seed)

    def test_two_case(self):
        """
        tests the very important two list case
        """
        list_1 = np.random.randn(list_length)
        list_2 = np.random.randn(list_length)
        mi_1_test, mi_2_test = min_idx(
            [list_1.reshape(1, list_length),
             list_2.reshape(1, list_length)])

        mi_1_control = np.arange(list_length)[list_1 < list_2]
        mi_2_control = np.arange(list_length)[list_1 >= list_2]
        self.assertTrue((mi_1_test == mi_1_control).all(), "idx minimums do not match")
        self.assertTrue((mi_2_test == mi_2_control).all(), "idx minimums do not match")

    def test_three_case(self):
        """
        tests the three list case
        """
        list_1 = np.random.randn(list_length)
        list_2 = np.random.randn(list_length)
        list_3 = np.random.randn(list_length)

# Path: mjhmc/misc/utils.py
# def min_idx(draws):
#     """
#     selects the argmin of the row wise minimum
#     returns a list of rows where each input draw was min
#     draws: a list of the various draws
# 
#     eg: draws = [fl_draws, f_draws] where fl_draws.shape = f_draws.shape = (1, N)
#     returns fl_idx, f_idx where fl_idx (and the others) are
#     arrays of shape (nbatch,) containing the indices of the rows where each variable was
#     the minimum
#     """
#     cdraws = np.concatenate(draws, axis=0)
#     transition_idx = np.argmin(cdraws, axis=0)
#     return [np.where(transition_idx == i)[0] for i in xrange(len(draws))]


# Path: mjhmc/tests/test_utils.py
import unittest
import numpy as np
from mjhmc.misc.utils import min_idx


class TestMinIdx(unittest.TestCase):
    """test that min idx works
    """

    def setUp(self):
        np.random.seed(n_seed)

    def test_two_case(self):
        """
        tests the very important two list case
        """
        list_1 = np.random.randn(list_length)
        list_2 = np.random.randn(list_length)
        mi_1_test, mi_2_test = min_idx(
            [list_1.reshape(1, list_length),
             list_2.reshape(1, list_length)])

        mi_1_control = np.arange(list_length)[list_1 < list_2]
        mi_2_control = np.arange(list_length)[list_1 >= list_2]
        self.assertTrue((mi_1_test == mi_1_control).all(), "idx minimums do not match")
        self.assertTrue((mi_2_test == mi_2_control).all(), "idx minimums do not match")

    def test_three_case(self):
        """
        tests the three list case
        """
        list_1 = np.random.randn(list_length)
        list_2 = np.random.randn(list_length)
        list_3 = np.random.randn(list_length)

        mi_1_test, mi_2_test, mi_3_test = min_idx(