# DO NOT EDIT this file. It is set up in such a way that if you make any edits,
# the test cases may change resulting in a broken local autograder.

# Imports
import sys

from test_rnn_toy import RNNToyTest
from test_gru_toy import GRUToyTest
from test_ctc_toy import CTCToyTest
from test import Test


rnn_test = RNNToyTest()
gru_test = GRUToyTest()
ctc_test = CTCToyTest()


test_list = {
    'rnn': [
        {'title': 'Section 2.1 - RNN Forward',
         'test': rnn_test.test_rnncell_forward,
         'score': 1
         },
        {'title': 'Section 2.2 - RNN Backward',
         'test': rnn_test.test_rnncell_backward,
         'score': 1
         },
        {'title': 'Section 2.3 - RNN Classifier',
         'test': rnn_test.test_rnn_classifier,
         'score': 1
         }
    ],
    'gru': [
        {'title': 'Section 3.1 - GRU Forward One Input',
         'test': gru_test.test_gru_forward_one_input,
         'score': 1
         },
        {'title': 'Section 3.2 - GRU Forward Three Input',
         'test': gru_test.test_gru_forward_three_input,
         'score': 1
         },
        {'title': 'Section 3.3 - GRU Backward',
         'test': gru_test.test_gru_backward,
         'score': 1
         }
    ],
    'ctc': [
        {'title': 'Section 4 - Extend Sequence with Blank',
        'test': ctc_test.test_ctc_extend_seq,
        'score': 1
        },
        {'title': 'Section 4 - Forward Probability',
        'test': ctc_test.test_ctc_forward_prob,
        'score': 1
        },
        {'title': 'Section 4 - Backward Probability',
        'test': ctc_test.test_ctc_backward_prob,
        'score': 1
        },
        {'title': 'Section 4 - Posterior Probability',
        'test': ctc_test.test_ctc_posterior_prob,
        'score': 1
        },
        {'title': 'Section 4.1 - CTC Forward',
        'test': ctc_test.test_ctc_forward,
        'score': 1
        },
        {'title': 'Section 4.2 - CTC Backward',
        'test': ctc_test.test_ctc_backward,
        'score': 1
        }
    ],
}

############################################################################################
########################## Test Cases - DO NOT EDIT ########################################
############################################################################################

if __name__ == "__main__":
    # # DO NOT EDIT
    if len(sys.argv) == 1:
        # run all tests
        tests = [test for sublist in test_list.values() for test in sublist]
        pass
    elif len(sys.argv) == 2:
        # run only tests for specified section
        test_type = sys.argv[1]
        if test_type in test_list:
            tests = test_list[test_type]
        else:
            sys.exit(
                'Invalid test type option provided.\nEnter one of [mcq, rnn, rnn_toy, gru, ctc, search.\nOr leave empty to run all tests.]')

    test = Test()
    for testcase in tests:
        test.run_tests(testcase['title'], testcase['test'], testcase['score'])

    # printing score summary
    print(f' {"_" * 42}{"_" * 16}')
    print(f'|{"TASK":<42}|{"" :<5}{"PASSED":<10}|')
    print(f'|{"_" * 42}|{"_" * 15}|')
    for title, score in test.scores.items():
        print(f'|{title:<42}|{"" :<5}{score:<10}|')
        print(f'|{"_" * 42}|{"_" * 15}|')
    print(f'|{"TOTAL PASSED":<42}|{"" :<5}{test.get_test_scores():<10}|')
    print(f'|{"_" * 42}|{"_" * 15}|')

# DO NOT EDIT this file. It is set up in such a way that if you make any edits,
# the test cases may change resulting in a broken local autograder.

# Imports
import sys

from test_rnn_toy import RNNToyTest
from test_gru_toy import GRUToyTest
from test_ctc_toy import CTCToyTest
from test import Test


rnn_test = RNNToyTest()
gru_test = GRUToyTest()
ctc_test = CTCToyTest()


test_list = {
    'rnn': [
        {'title': 'Section 2.1 - RNN Forward',
         'test': rnn_test.test_rnncell_forward,
         'score': 1
         },
        {'title': 'Section 2.2 - RNN Backward',
         'test': rnn_test.test_rnncell_backward,
         'score': 1
         },
        {'title': 'Section 2.3 - RNN Classifier',
         'test': rnn_test.test_rnn_classifier,
         'score': 1
         }
    ],
    'gru': [
        {'title': 'Section 3.1 - GRU Forward One Input',
         'test': gru_test.test_gru_forward_one_input,
         'score': 1
         },
        {'title': 'Section 3.2 - GRU Forward Three Input',
         'test': gru_test.test_gru_forward_three_input,
         'score': 1
         },
        {'title': 'Section 3.3 - GRU Backward',
         'test': gru_test.test_gru_backward,
         'score': 1
         }
    ],
    'ctc': [
        {'title': 'Section 4 - Extend Sequence with Blank',
        'test': ctc_test.test_ctc_extend_seq,
        'score': 1
        },
        {'title': 'Section 4 - Forward Probability',
        'test': ctc_test.test_ctc_forward_prob,
        'score': 1
        },
        {'title': 'Section 4 - Backward Probability',
        'test': ctc_test.test_ctc_backward_prob,
        'score': 1
        },
        {'title': 'Section 4 - Posterior Probability',
        'test': ctc_test.test_ctc_posterior_prob,
        'score': 1
        },
        {'title': 'Section 4.1 - CTC Forward',
        'test': ctc_test.test_ctc_forward,
        'score': 1
        },
        {'title': 'Section 4.2 - CTC Backward',
        'test': ctc_test.test_ctc_backward,
        'score': 1
        }
    ],
}

############################################################################################
########################## Test Cases - DO NOT EDIT ########################################
############################################################################################

if __name__ == "__main__":
    # # DO NOT EDIT
    if len(sys.argv) == 1:
        # run all tests
        tests = [test for sublist in test_list.values() for test in sublist]
        pass
    elif len(sys.argv) == 2:
        # run only tests for specified section
        test_type = sys.argv[1]
        if test_type in test_list:
            tests = test_list[test_type]
        else:
            sys.exit(
                'Invalid test type option provided.\nEnter one of [mcq, rnn, rnn_toy, gru, ctc, search.\nOr leave empty to run all tests.]')

    test = Test()
    for testcase in tests:
        test.run_tests(testcase['title'], testcase['test'], testcase['score'])

    # printing score summary
    print(f' {"_" * 42}{"_" * 16}')
    print(f'|{"TASK":<42}|{"" :<5}{"PASSED":<10}|')
    print(f'|{"_" * 42}|{"_" * 15}|')
    for title, score in test.scores.items():
        print(f'|{title:<42}|{"" :<5}{score:<10}|')
        print(f'|{"_" * 42}|{"_" * 15}|')
    print(f'|{"TOTAL PASSED":<42}|{"" :<5}{test.get_test_scores():<10}|')
    print(f'|{"_" * 42}|{"_" * 15}|')

# DO NOT EDIT this file. It is set up in such a way that if you make any edits, # the test cases may change resulting in a broken local autograder. # Imports ############################################################################################ ########################## Test Cases - DO NOT EDIT ######################################## ############################################################################################ # # DO NOT EDIT # run all tests # run only tests for specified section # printing score summary