def enum_verified(self): t = Tiling(obstructions=[ GriddedPerm((0, 1), ((0, 0), ) * 2), GriddedPerm((0, 1), ((0, 1), ) * 2), GriddedPerm((0, 1), ((0, 2), ) * 2), GriddedPerm((0, 1), ((2, 0), ) * 2), GriddedPerm((0, 1, 2), ((1, 1), ) * 3), ]) return MonotoneTreeEnumeration(t)
def test_get_genf_simple(self): t = Tiling(obstructions=[ GriddedPerm((0, 1), ((0, 0), ) * 2), GriddedPerm((1, 0), ((1, 0), ) * 2), ]) enum = MonotoneTreeEnumeration(t) print(t) assert enum.verified() assert sympy.simplify(enum.get_genf() - sympy.sympify("1/(1-2*x)")) == 0
def test_with_finite_monotone_cell(self): t = Tiling(obstructions=[ GriddedPerm((0, 1), ((0, 0), ) * 2), GriddedPerm((1, 0), ((0, 0), ) * 2), GriddedPerm((0, 1), ((1, 0), ) * 2), GriddedPerm((1, 0), ((1, 0), ) * 2), ]) enum = MonotoneTreeEnumeration(t) print(t) assert enum.verified() assert enum.get_genf().expand() == sympy.sympify("1+2*x+2*x**2")
def test_with_finite_monotone_cell2(self): t = Tiling(obstructions=[ GriddedPerm((0, 1), ((0, 0), ) * 2), GriddedPerm((1, 0), ((0, 1), ) * 2), GriddedPerm((0, 1), ((0, 1), ) * 2), GriddedPerm((1, 0), ((1, 1), ) * 2), ]) enum = MonotoneTreeEnumeration(t) print(t) assert enum.verified() assert (sympy.sympify("x/(1-x)**4 + 1/(1-x)**2") - enum.get_genf()).simplify() == 0
def enum_with_list_req(self): t = Tiling( obstructions=[ GriddedPerm((0, 1), ((0, 0), (0, 0))), GriddedPerm((0, 1), ((1, 0), (1, 0))), ], requirements=[[ GriddedPerm((0, ), ((0, 0), )), GriddedPerm((0, ), ((1, 0), )), ]], ) return MonotoneTreeEnumeration(t)
def test_get_genf(self, enum_verified): x = sympy.Symbol("x") expected_gf = -(sympy.sqrt(-(4 * x**3 - 14 * x**2 + 8 * x - 1) / (2 * x**2 - 4 * x + 1)) - 1) / ( 2 * x * (x**2 - 3 * x + 1)) assert sympy.simplify(enum_verified.get_genf() - expected_gf) == 0 t = Tiling(obstructions=[ GriddedPerm((0, 1), ((0, 0), ) * 2), GriddedPerm((0, 1), ((1, 0), ) * 2), ]) enum_no_start = MonotoneTreeEnumeration(t) expected_gf = -1 / ((x - 1) * (x / (x - 1) + 1)) assert sympy.simplify(enum_no_start.get_genf() - expected_gf) == 0
def test_corner(self): t = Tiling( obstructions=( GriddedPerm((0, ), ((1, 1), )), GriddedPerm((0, 1), ((0, 0), (0, 0))), GriddedPerm((0, 1), ((0, 1), (0, 1))), GriddedPerm((0, 1), ((1, 0), (1, 0))), ), requirements=((GriddedPerm((0, ), ((0, 0), )), ), ), ) enum = MonotoneTreeEnumeration(t) expected_enum = [0, 1, 5, 17, 50, 138, 370, 979, 2575, 6755, 17700] assert enum.verified() assert taylor_expand(enum.get_genf()) == expected_enum
def test_genf_with_big_finite_cell(self): t = Tiling(obstructions=[ GriddedPerm((0, 1), ((0, 0), ) * 2), GriddedPerm((0, 1), ((1, 0), ) * 2), GriddedPerm((3, 2, 1, 0), ((0, 0), ) * 4), GriddedPerm((3, 2, 1, 0), ((1, 0), ) * 4), ]) enum = MonotoneTreeEnumeration(t) print(t) assert enum.verified() genf = enum.get_genf().expand() x = sympy.var("x") assert (genf == 1 + 2 * x + 4 * x**2 + 8 * x**3 + 14 * x**4 + 20 * x**5 + 20 * x**6)
def test_genf_with_req(self): t = Tiling( obstructions=[ GriddedPerm((0, 1), ((0, 0), ) * 2), GriddedPerm((0, 1), ((1, 0), ) * 2), ], requirements=[ [GriddedPerm((1, 0), ((0, 0), ) * 2)], [GriddedPerm((0, ), ((1, 0), ))], ], ) enum = MonotoneTreeEnumeration(t) print(t) assert enum.verified() genf = enum.get_genf().expand() terms = [0, 0, 0, 3, 10, 25, 56, 119, 246, 501, 1012] assert taylor_expand(genf) == terms
def test_not_verified(self, enum_with_list_req, onebyone_enum, enum_with_crossing): assert not enum_with_crossing.verified() assert not enum_with_list_req.verified() assert not onebyone_enum.verified() forest_tiling = Tiling( obstructions=[ GriddedPerm((0, ), ((0, 0), )), GriddedPerm((0, ), ((1, 1), )), GriddedPerm((0, ), ((2, 1), )), GriddedPerm((0, 1), ((1, 0), (1, 0))), GriddedPerm((0, 1), ((2, 0), (2, 0))), GriddedPerm((0, 1, 2), ((0, 1), (0, 1), (0, 1))), ], requirements=[[GriddedPerm((0, ), ((0, 1), ))]], ) assert not MonotoneTreeEnumeration(forest_tiling).verified()
def test_with_two_reqs(self): t = Tiling( obstructions=( GriddedPerm((0, ), ((1, 1), )), GriddedPerm((0, 1), ((0, 0), (0, 0))), GriddedPerm((0, 1), ((0, 1), (0, 1))), GriddedPerm((0, 1), ((1, 0), (1, 0))), GriddedPerm((1, 0), ((0, 1), (0, 1))), ), requirements=( (GriddedPerm((0, ), ((0, 0), )), ), (GriddedPerm((0, ), ((0, 1), )), ), ), ) enum = MonotoneTreeEnumeration(t) expected_enum = [0, 0, 2, 7, 19, 47, 111, 255, 575, 1279, 2815] assert enum.verified() assert taylor_expand(enum.get_genf()) == expected_enum
def onebyone_enum(self): return MonotoneTreeEnumeration(Tiling.from_string("123"))