<commit_before>import markov_tool as mt

ins = mt.InstanceList()

if ins._get_native_types() != (0, {}):
    print "There was a problem instantiating the InstanceList."
    print ins._get_native_types()

ins['a'] = 1
if ins['a'] != 1 or ins._get_native_types() != (1, {'a': 1}):
    print "There was a problem setting/getting an item."
    print ins._get_native_types()

ins['a'] += 1
if ins['a'] != 2 or ins._get_native_types() != (2, {'a': 2}):
    print "There was a problem setting/getting an item."
    print ins._get_native_types()

ins['b'] = 2

result = ins._InstanceList__get_next_token(lambda x, y: 0)
if result != 'a':
    print "There was a problem getting the next token (value: 0). Actual value: " + \
    str(result)
    print ins._get_native_types()

result = ins._InstanceList__get_next_token(lambda x, y: 1)
if result != 'a':
    print "There was a problem getting the next token (value: 1). Actual value: " + \
    str(result)
    print ins._get_native_types()

result = ins._InstanceList__get_next_token(lambda x, y: 2)
if result != 'b':
    print "There was a problem getting the next token (value: 2). Actual value: " + \
    str(result)
    print ins._get_native_types()

instance = mt.InstanceMatrix()

instance._add_elem('a', 'b')
if {'a': {'b': 1}} != instance._get_matrix():
    print "There was a problem adding a new top-level element."
    print instance._get_matrix()

instance._add_elem('a', 'c')
if {'a': {'b': 1, 'c': 1}} != instance._get_matrix():
    print "There was a problem adding a new second-level element."
    print instance._get_matrix()

instance._add_elem('a', 'c')
if {'a': {'b': 1, 'c': 2}} != instance._get_matrix():
    print "There was a problem updating a second-level element."
    print instance._get_matrix()

instance = mt.InstanceMatrix()

instance.load('this')
if {'': {'t': 1}, 't': {'h': 1}, 'h': {'i': 1}, 'i': {'s': 1}, 's': {'': 1}} != instance._get_matrix():
    print "There was a problem loading a string into the Instance Matrix."

print "Tests finished."

<commit_msg>Removing reliance on underlying data structures in the tests, adding some tests that will throw errors, adding actual chain generation!<commit_after>import markov_tool as mt

ins = mt.InstanceList()

if ins._get_native_types() != (0, {}):
    print "There was a problem instantiating the InstanceList."
    print ins._get_native_types()

ins['a'] = 1
if ins['a'] != 1 or ins._get_native_types() != (1, {'a': 1}):
    print "There was a problem setting/getting an item."
    print ins._get_native_types()

ins['a'] += 1
if ins['a'] != 2 or ins._get_native_types() != (2, {'a': 2}):
    print "There was a problem setting/getting an item."
    print ins._get_native_types()

ins['b'] = 2

result = ins._InstanceList__get_next_token(lambda x, y: 0)
if result != 'a':
    print "There was a problem getting the next token (value: 0). Actual value: " + \
    str(result)
    print ins._get_native_types()

result = ins._InstanceList__get_next_token(lambda x, y: 1)
if result != 'a':
    print "There was a problem getting the next token (value: 1). Actual value: " + \
    str(result)
    print ins._get_native_types()

result = ins._InstanceList__get_next_token(lambda x, y: 2)
if result != 'b':
    print "There was a problem getting the next token (value: 2). Actual value: " + \
    str(result)
    print ins._get_native_types()

result = ins._InstanceList__get_next_token(lambda x, y: 3)
if result != 'b':
    print "There was a problem getting the next token (value: 3). Actual value: " + \
    str(result)
    print ins._get_native_types()

try:
    result = ins._InstanceList__get_next_token(lambda x, y: 4)
except IndexError as e:
    print "Caught Index error"
else:
    print "We didn't catch any errors, and that's a problem."

instance = mt.InstanceMatrix()

instance.load('this')

a = instance.generate()
if a != "this":
    print "There was a problem generating from the instance matrix."
    print "Result: " + a

print "Tests finished."

{'fraction_non_alphanumeric': 0.14626191670847968, 'fraction_numerical': 0.011289513296537882, 'mean_word_length': 3.904059040590406, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3045724', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1301, 'n_words': 453}