def test_fit_xy(fps, w, h, ow, oh, boundary_effect, boundary_effect_locus): """ Compares tiling versus truth that is manually inputed Handles combinations of parameters where all tiles fit inside origin """ if (1, 1, 0, 0) == (w, h, ow, oh): truth = [ [fps.G, fps.H, fps.I, ], [fps.L, fps.M, fps.N, ], [fps.Q, fps.R, fps.S, ], ] elif (1, 2, 0, 1) == (w, h, ow, oh): truth = [ [fps.GL, fps.HM, fps.IN], [fps.LQ, fps.MR, fps.NS], ] elif (1, 3, 0, ANY) == (w, h, ow, ANY): truth = [ [fps.GQ, fps.HR, fps.IS, ], ] elif (2, 1, 1, 0) == (w, h, ow, oh): truth = [ [fps.GH, fps.HI], [fps.LM, fps.MN], [fps.QR, fps.RS], ] elif (2, 2, 1, 1) == (w, h, ow, oh): truth = [ [fps.GM, fps.HN], [fps.LR, fps.MS], ] elif (2, 3, 1, ANY) == (w, h, ow, ANY): truth = [ [fps.GR, fps.HS], ] elif (3, 1, ANY, 0) == (w, h, ANY, oh): truth = [ [fps.GI, ], [fps.LN, ], [fps.QS, ], ] elif (3, 2, ANY, 1) == (w, h, ANY, oh): truth = [ [fps.GN], [fps.LS], ] elif (3, 3, ANY, ANY) == (w, h, ANY, ANY): truth = [ [fps.GS, ], ] else: raise Exception('Test %s not implemented' % str((w, h, ow, oh))) tiles = fps.GS.tile( (w, h), ow, oh, boundary_effect=boundary_effect, boundary_effect_locus=boundary_effect_locus ) assert_tiles_eq(tiles, truth)
def test_extra(fps, w, h, ow, oh, boundary_effect, boundary_effect_locus): if (2, 2, 0, 1) == (w, h, ow, oh): if boundary_effect_locus == 'tr': if boundary_effect == 'extend': truth = [ [fps.GM, fps.IO], [fps.LR, fps.NT], ] elif boundary_effect == 'overlap': truth = [ [fps.GM, fps.HN], [fps.LR, fps.MS], ] elif boundary_effect == 'exclude': truth = [ [fps.GM], [fps.LR], ] elif boundary_effect == 'shrink': truth = [ [fps.GM, fps.IN], [fps.LR, fps.NS], ] else: assert False elif boundary_effect_locus == 'tl' or boundary_effect_locus == 'bl': if boundary_effect == 'extend': truth = [ [fps.FL, fps.HN], [fps.KQ, fps.MS], ] elif boundary_effect == 'overlap': truth = [ [fps.GM, fps.HN], [fps.LR, fps.MS], ] elif boundary_effect == 'exclude': truth = [ [fps.HN], [fps.MS], ] elif boundary_effect == 'shrink': truth = [ [fps.GL, fps.HN], [fps.LQ, fps.MS], ] else: assert False else: assert False tiles = fps.GS.tile( (w, h), ow, oh, boundary_effect=boundary_effect, boundary_effect_locus=boundary_effect_locus ) assert_tiles_eq(tiles, truth)
def test_nofit_xy_br_exclude(fps, w, h, ow, oh): """ Compares tiling versus truth that is manually inputed Handles combinations of parameters where all tiles DO NOT fit inside origin for 'exclude' parameter """ if (1, 2, 0, 0) == (w, h, ow, oh): truth = [ [fps.GL, fps.HM, fps.IN], ] elif (2, 1, 0, 0) == (w, h, ow, oh): truth = [ [fps.GH, ], [fps.LM, ], [fps.QR, ], ] elif (2, 2, 0, 0) == (w, h, ow, oh): truth = [ [fps.GM, ], ] elif (2, 2, 0, 1) == (w, h, ow, oh): truth = [ [fps.GM, ], [fps.LR, ], ] elif (2, 2, 1, 0) == (w, h, ow, oh): truth = [ [fps.GM, fps.HN], ] elif (2, 3, 0, ANY) == (w, h, ow, ANY): truth = [ [fps.GR, ], ] elif (3, 2, ANY, 0) == (w, h, ANY, oh): truth = [ [fps.GN], ] elif (4, ANY, ANY, ANY) == (w, ANY, ANY, ANY): truth = [] elif (ANY, 4, ANY, ANY) == (ANY, h, ANY, ANY): truth = [] else: raise Exception('Test %s not implemented' % str((w, h, ow, oh))) tiles = fps.GS.tile((w, h), ow, oh, boundary_effect='exclude') assert_tiles_eq(tiles, truth)
def test_nofit_xy_br_overlap(fps, w, h, ow, oh): """ Compares tiling versus truth that is manually inputed Handles combinations of parameters where all tiles DO NOT fit inside origin for 'overlap' parameter """ if (1, 2, 0, 0) == (w, h, ow, oh): truth = [ [fps.GL, fps.HM, fps.IN, ], [fps.LQ, fps.MR, fps.NS, ], ] elif (2, 1, 0, 0) == (w, h, ow, oh): truth = [ [fps.GH, fps.HI, ], [fps.LM, fps.MN, ], [fps.QR, fps.RS, ], ] elif (2, 2, ANY, ANY) == (w, h, ANY, ANY): truth = [ [fps.GM, fps.HN, ], [fps.LR, fps.MS, ], ] elif (2, 3, 0, ANY) == (w, h, ow, ANY): truth = [ [fps.GR, fps.HS, ], ] elif (3, 2, ANY, 0) == (w, h, ANY, oh): truth = [ [fps.GN], [fps.LS], ] elif ((4, ANY, ANY, ANY) == (w, ANY, ANY, ANY) or (ANY, 4, ANY, ANY) == (ANY, h, ANY, ANY)): with pytest.raises(ValueError, match='overlap'): _ = fps.GS.tile((w, h), ow, oh, boundary_effect='overlap') return else: raise Exception('Test %s not implemented' % str((w, h, ow, oh))) tiles = fps.GS.tile((w, h), ow, oh, boundary_effect='overlap') assert_tiles_eq(tiles, truth)
def test_nofit_xy_br_shrink(fps, w, h, ow, oh): """ Compares tiling versus truth that is manually inputed Handles combinations of parameters where all tiles DO NOT fit inside origin for 'shrink' parameter """ if (1, 2, 0, 0) == (w, h, ow, oh): truth = [ [fps.GL, fps.HM, fps.IN, ], [fps.Q, fps.R, fps.S, ], ] elif (2, 1, 0, 0) == (w, h, ow, oh): truth = [ [fps.GH, fps.I, ], [fps.LM, fps.N, ], [fps.QR, fps.S, ], ] elif (2, 2, 0, 0) == (w, h, ow, oh): truth = [ [fps.GM, fps.IN, ], [fps.QR, fps.S, ], ] elif (2, 2, 0, 1) == (w, h, ow, oh): truth = [ [fps.GM, fps.IN], [fps.LR, fps.NS], ] elif (2, 2, 1, 0) == (w, h, ow, oh): truth = [ [fps.GM, fps.HN], [fps.QR, fps.RS], ] elif ((2, 3, 0, ANY) == (w, h, ow, ANY) or (2, 4, 0, ANY) == (w, h, ow, ANY)): truth = [ [fps.GR, fps.IS, ], ] elif ((3, 2, ANY, 0) == (w, h, ANY, oh) or (4, 2, ANY, 0) == (w, h, ANY, oh)): truth = [ [fps.GN], [fps.QS], ] elif ((3, 4, ANY, ANY) == (w, h, ANY, ANY) or (4, 3, ANY, ANY) == (w, h, ANY, ANY) or (4, 4, ANY, ANY) == (w, h, ANY, ANY)): truth = [ [fps.GS], ] elif (1, 4, 0, ANY) == (w, h, ow, ANY): truth = [ [fps.GQ, fps.HR, fps.IS], ] elif (4, 1, ANY, 0) == (w, h, ANY, oh): truth = [ [fps.GI], [fps.LN], [fps.QS], ] elif (4, 2, ANY, 1) == (w, h, ANY, oh): truth = [ [fps.GN], [fps.LS], ] elif (2, 4, 1, ANY) == (w, h, ow, ANY): truth = [ [fps.GR, fps.HS], ] else: raise Exception('Test %s not implemented' % str((w, h, ow, oh))) tiles = fps.GS.tile((w, h), ow, oh, boundary_effect='shrink') assert_tiles_eq(tiles, truth)
def test_nofit_xy_br_extend(fps, w, h, ow, oh): """ Compares tiling versus truth that is manually inputed Handles combinations of parameters where all tiles DO NOT fit inside origin for 'extend' parameter """ if (1, 2, 0, 0) == (w, h, ow, oh): truth = [ [fps.GL, fps.HM, fps.IN, ], [fps.QV, fps.RW, fps.SX, ], ] elif (2, 1, 0, 0) == (w, h, ow, oh): truth = [ [fps.GH, fps.IJ, ], [fps.LM, fps.NO, ], [fps.QR, fps.ST, ], ] elif (2, 2, 0, 0) == (w, h, ow, oh): truth = [ [fps.GM, fps.IO, ], [fps.QW, fps.SY, ], ] elif (2, 2, 0, 1) == (w, h, ow, oh): truth = [ [fps.GM, fps.IO], [fps.LR, fps.NT], ] elif (2, 2, 1, 0) == (w, h, ow, oh): truth = [ [fps.GM, fps.HN], [fps.QW, fps.RX], ] elif (2, 3, 0, ANY) == (w, h, ow, ANY): truth = [ [fps.GR, fps.IT, ], ] elif (3, 2, ANY, 0) == (w, h, ANY, oh): truth = [ [fps.GN], [fps.QX], ] elif (4, 1, ANY, 0) == (w, h, ANY, oh): truth = [ [fps.GJ], [fps.LO], [fps.QT], ] elif (4, 2, ANY, 0) == (w, h, ANY, oh): truth = [ [fps.GO], [fps.QY], ] elif (4, 2, ANY, 1) == (w, h, ANY, oh): truth = [ [fps.GO], [fps.LT], ] elif (4, 3, ANY, ANY) == (w, h, ANY, ANY): truth = [ [fps.GT], ] elif (4, 4, ANY, ANY) == (w, h, ANY, ANY): truth = [ [fps.GY], ] elif (1, 4, 0, ANY) == (w, h, ow, ANY): truth = [ [fps.GV, fps.HW, fps.IX], ] elif (2, 4, 0, ANY) == (w, h, ow, ANY): truth = [ [fps.GW, fps.IY], ] elif (2, 4, 1, ANY) == (w, h, ow, ANY): truth = [ [fps.GW, fps.HX], ] elif (3, 4, ANY, ANY) == (w, h, ANY, ANY): truth = [ [fps.GX], ] else: raise Exception('Test %s not implemented' % str((w, h, ow, oh))) tiles = fps.GS.tile((w, h), ow, oh, boundary_effect='extend') assert_tiles_eq(tiles, truth)
def test_success(fps, w, h, pox, poy): # Tiles of area 1 if (1, 1, 1, 1) == (w, h, pox, poy): truth = [ [fps.Q, fps.R, fps.S], [fps.X, fps.Y, fps.Z], [fps.e, fps.f, fps.g], ] # Tiles of area 2 elif (2, 1, 1, 1) == (w, h, pox, poy): truth = [ [fps.QR, fps.ST], [fps.XY, fps.Za], [fps.ef, fps.gh], ] elif (2, 1, 2, 1) == (w, h, pox, poy): truth = [ [fps.PQ, fps.QR, fps.RS, fps.ST], [fps.WX, fps.XY, fps.YZ, fps.Za], [fps.de, fps.ef, fps.fg, fps.gh], ] elif (1, 2, 1, 1) == (w, h, pox, poy): truth = [ [fps.QX, fps.RY, fps.SZ], [fps.el, fps.fm, fps.gn], ] elif (1, 2, 1, 2) == (w, h, pox, poy): truth = [ [fps.JQ, fps.KR, fps.LS], [fps.QX, fps.RY, fps.SZ], [fps.Xe, fps.Yf, fps.Zg], [fps.el, fps.fm, fps.gn], ] # Tiles of area 3 elif (1, 3, 1, 1) == (w, h, pox, poy): truth = [ [fps.Qe, fps.Rf, fps.Sg, ], ] elif (1, 3, 1, 3) == (w, h, pox, poy): truth = [ [fps.CQ, fps.DR, fps.ES, ], [fps.JX, fps.KY, fps.LZ, ], [fps.Qe, fps.Rf, fps.Sg, ], [fps.Xl, fps.Ym, fps.Zn, ], [fps.es, fps.ft, fps.gu, ], ] elif (3, 1, 1, 1) == (w, h, pox, poy): truth = [ [fps.QS, ], [fps.XZ, ], [fps.eg, ], ] elif (3, 1, 3, 1) == (w, h, pox, poy): truth = [ [fps.OQ, fps.PR, fps.QS, fps.RT, fps.SU, ], [fps.VX, fps.WY, fps.XZ, fps.Ya, fps.Zb, ], [fps.ce, fps.df, fps.eg, fps.fh, fps.gi, ], ] # Tiles of area 4 elif (2, 2, 1, 1) == (w, h, pox, poy): truth = [ [fps.QY, fps.Sa], [fps.em, fps.go], ] elif (2, 2, 2, 1) == (w, h, pox, poy): truth = [ [fps.PX, fps.QY, fps.RZ, fps.Sa], [fps.dl, fps.em, fps.fn, fps.go], ] elif (2, 2, 1, 2) == (w, h, pox, poy): truth = [ [fps.JR, fps.LT], [fps.QY, fps.Sa], [fps.Xf, fps.Zh], [fps.em, fps.go], ] elif (2, 2, 2, 2) == (w, h, pox, poy): truth = [ [fps.IQ, fps.JR, fps.KS, fps.LT], [fps.PX, fps.QY, fps.RZ, fps.Sa], [fps.We, fps.Xf, fps.Yg, fps.Zh], [fps.dl, fps.em, fps.fn, fps.go], ] # Tiles of area 6 elif (2, 3, 1, 1) == (w, h, pox, poy): truth = [ [fps.Qf, fps.Sh], ] elif (2, 3, 2, 1) == (w, h, pox, poy): truth = [ [fps.Pe, fps.Qf, fps.Rg, fps.Sh, ], ] elif (2, 3, 1, 3) == (w, h, pox, poy): truth = [ [fps.CR, fps.ET, ], [fps.JY, fps.La, ], [fps.Qf, fps.Sh, ], [fps.Xm, fps.Zo, ], [fps.et, fps.gv, ], ] elif (2, 3, 2, 3) == (w, h, pox, poy): truth = [ [fps.BQ, fps.CR, fps.DS, fps.ET, ], [fps.IX, fps.JY, fps.KZ, fps.La, ], [fps.Pe, fps.Qf, fps.Rg, fps.Sh, ], [fps.Wl, fps.Xm, fps.Yn, fps.Zo, ], [fps.ds, fps.et, fps.fu, fps.gv, ], ] elif (3, 2, 1, 1) == (w, h, pox, poy): truth = [ [fps.QZ], [fps.en], ] elif (3, 2, 1, 2) == (w, h, pox, poy): truth = [ [fps.JS, ], [fps.QZ, ], [fps.Xg, ], [fps.en, ], ] elif (3, 2, 3, 1) == (w, h, pox, poy): truth = [ [fps.OX, fps.PY, fps.QZ, fps.Ra, fps.Sb, ], [fps.cl, fps.dm, fps.en, fps.fo, fps.gp, ], ] elif (3, 2, 3, 2) == (w, h, pox, poy): truth = [ [fps.HQ, fps.IR, fps.JS, fps.KT, fps.LU, ], [fps.OX, fps.PY, fps.QZ, fps.Ra, fps.Sb, ], [fps.Ve, fps.Wf, fps.Xg, fps.Yh, fps.Zi, ], [fps.cl, fps.dm, fps.en, fps.fo, fps.gp, ], ] # Tiles of area 9 elif (3, 3, 1, 1) == (w, h, pox, poy): truth = [ [fps.Qg], ] elif (3, 3, 1, 3) == (w, h, pox, poy): truth = [ [fps.CS, ], [fps.JZ, ], [fps.Qg, ], [fps.Xn, ], [fps.eu, ], ] elif (3, 3, 3, 1) == (w, h, pox, poy): truth = [ [fps.Oe, fps.Pf, fps.Qg, fps.Rh, fps.Si, ], ] elif (3, 3, 3, 3) == (w, h, pox, poy): truth = [ [fps.AQ, fps.BR, fps.CS, fps.DT, fps.EU], [fps.HX, fps.IY, fps.JZ, fps.Ka, fps.Lb], [fps.Oe, fps.Pf, fps.Qg, fps.Rh, fps.Si], [fps.Vl, fps.Wm, fps.Xn, fps.Yo, fps.Zp], [fps.cs, fps.dt, fps.eu, fps.fv, fps.gw], ] else: raise Exception('Test %s not implemented' % str((w, h, pox, poy))) tiles = fps.Qg.tile_occurrence((w, h), pox, poy) assert_tiles_eq(tiles, truth) for f in SUCCESS_ASSERTS: f(fps.Qg, tiles, (w, h), pox, poy, 'tl')