# Path: preimage/utils/alphabet.py
# class Alphabet:
# def get_n_gram_to_index(alphabet, n):
# def get_index_to_n_gram(alphabet, n):
# def get_n_grams(alphabet, n):
# def transform_strings_to_integer_lists(Y, alphabet):
# 
# Path: preimage/exceptions/n_gram.py
# class InvalidNGramLengthError(ValueError):
#     def __init__(self, n, min_n=0):
#         self.n = n
#         self.min_n = min_n
# 
#     def __str__(self):
#         error_message = 'n must be greater than {:d}. Got: n={:d}'.format(self.min_n, self.n)
#         return error_message


import unittest2
import numpy.testing
from preimage.utils import alphabet
from preimage.exceptions.n_gram import InvalidNGramLengthError
__author__ = 'amelie'




class TestAlphabet(unittest2.TestCase):
    def setUp(self):
        self.a_b_alphabet = ['a', 'b']
        self.abc_alphabet = ['a', 'b', 'c']
        self.two_grams = ['aa', 'ab', 'ba', 'bb']
        self.one_gram_to_index = {'a': 0, 'b': 1}
        self.two_gram_to_index = {'aa': 0, 'ab': 1, 'ba': 2, 'bb': 3}
        self.index_to_one_gram = {0: 'a', 1: 'b'}
        self.index_to_two_gram = {0: 'aa', 1: 'ab', 2: 'ba', 3: 'bb'}
        self.cab = ['cab']
        self.cab_aa = ['cab', 'aa']
        self.cab_int = [[2, 0, 1]]
        self.cab_aa_int = [[2, 0, 1], [0, 0, -1]]

    def test_integer_n_is_zero_get_n_grams_raises_value_error(self):
        with self.assertRaises(ValueError):

# Path: preimage/utils/alphabet.py
# class Alphabet:
# def get_n_gram_to_index(alphabet, n):
# def get_index_to_n_gram(alphabet, n):
# def get_n_grams(alphabet, n):
# def transform_strings_to_integer_lists(Y, alphabet):
# 
# Path: preimage/exceptions/n_gram.py
# class InvalidNGramLengthError(ValueError):
#     def __init__(self, n, min_n=0):
#         self.n = n
#         self.min_n = min_n
# 
#     def __str__(self):
#         error_message = 'n must be greater than {:d}. Got: n={:d}'.format(self.min_n, self.n)
#         return error_message


# Path: preimage/tests/utils/test_alphabet.py
import unittest2
import numpy.testing
from preimage.utils import alphabet
from preimage.exceptions.n_gram import InvalidNGramLengthError

__author__ = 'amelie'




class TestAlphabet(unittest2.TestCase):
    def setUp(self):
        self.a_b_alphabet = ['a', 'b']
        self.abc_alphabet = ['a', 'b', 'c']
        self.two_grams = ['aa', 'ab', 'ba', 'bb']
        self.one_gram_to_index = {'a': 0, 'b': 1}
        self.two_gram_to_index = {'aa': 0, 'ab': 1, 'ba': 2, 'bb': 3}
        self.index_to_one_gram = {0: 'a', 1: 'b'}
        self.index_to_two_gram = {0: 'aa', 1: 'ab', 2: 'ba', 3: 'bb'}
        self.cab = ['cab']
        self.cab_aa = ['cab', 'aa']
        self.cab_int = [[2, 0, 1]]
        self.cab_aa_int = [[2, 0, 1], [0, 0, -1]]

    def test_integer_n_is_zero_get_n_grams_raises_value_error(self):
        with self.assertRaises(ValueError):

            alphabet.get_n_grams(self.a_b_alphabet, n=0.5)