def test_lookup_table_3_with_twist(self): n_tokens = 3 catalan_pyramid = CatalanPyramid() catalan_pyramid.access(0, 0, 10) # populate extra rows. depth = n_tokens - 1 width = n_tokens * 2 - 1 for i in range(width): for n_reduces in range(depth): actual = catalan_pyramid.access(n_reduces, i, n_tokens) expected = target_3[n_reduces][i] assert almost_equal(actual, expected), "\nRet: {}\nExp: {}".format( actual, expected)
def test_large(self): n_tokens = 1000 n_reduces = 3 i = 10 # expected = ? catalan_pyramid = CatalanPyramid() # causes OverflowError when dividing long ints actual = catalan_pyramid.access(n_reduces, i, n_tokens)
def test_lookup_table_12_random_access(self): n_tokens = 12 n_reduces = 3 i = 10 expected = 0.480769230769 catalan_pyramid = CatalanPyramid() actual = catalan_pyramid.access(n_reduces, i, n_tokens) assert almost_equal(actual, expected), "\nRet: {}\nExp: {}".format( actual, expected)
def test_lookup_table_12(self): n_tokens = 12 catalan_pyramid = CatalanPyramid() depth = n_tokens - 1 width = n_tokens * 2 - 1 for i in range(width): for n_reduces in range(depth): actual = catalan_pyramid.access(n_reduces, i, n_tokens) expected = target_12[n_reduces][i] assert almost_equal(actual, expected), "\nRet: {}\nExp: {}".format( actual, expected)