1import fontTools.varLib.iup as iup 2import sys 3import pytest 4 5 6class IupTest: 7 # ----- 8 # Tests 9 # ----- 10 11 @pytest.mark.parametrize( 12 "delta, coords, forced", 13 [ 14 ([(0, 0)], [(1, 2)], set()), 15 ([(0, 0), (0, 0), (0, 0)], [(1, 2), (3, 2), (2, 3)], set()), 16 ( 17 [(1, 1), (-1, 1), (-1, -1), (1, -1)], 18 [(0, 0), (2, 0), (2, 2), (0, 2)], 19 set(), 20 ), 21 ( 22 [ 23 (-1, 0), 24 (-1, 0), 25 (-1, 0), 26 (-1, 0), 27 (-1, 0), 28 (0, 0), 29 (0, 0), 30 (0, 0), 31 (0, 0), 32 (0, 0), 33 (0, 0), 34 (-1, 0), 35 ], 36 [ 37 (-35, -152), 38 (-86, -101), 39 (-50, -65), 40 (0, -116), 41 (51, -65), 42 (86, -99), 43 (35, -151), 44 (87, -202), 45 (51, -238), 46 (-1, -187), 47 (-53, -239), 48 (-88, -205), 49 ], 50 {11}, 51 ), 52 ( 53 [ 54 (0, 0), 55 (1, 0), 56 (2, 0), 57 (2, 0), 58 (0, 0), 59 (1, 0), 60 (3, 0), 61 (3, 0), 62 (2, 0), 63 (2, 0), 64 (0, 0), 65 (0, 0), 66 (-1, 0), 67 (-1, 0), 68 (-1, 0), 69 (-3, 0), 70 (-1, 0), 71 (0, 0), 72 (0, 0), 73 (-2, 0), 74 (-2, 0), 75 (-1, 0), 76 (-1, 0), 77 (-1, 0), 78 (-4, 0), 79 ], 80 [ 81 (330, 65), 82 (401, 65), 83 (499, 117), 84 (549, 225), 85 (549, 308), 86 (549, 422), 87 (549, 500), 88 (497, 600), 89 (397, 648), 90 (324, 648), 91 (271, 648), 92 (200, 620), 93 (165, 570), 94 (165, 536), 95 (165, 473), 96 (252, 407), 97 (355, 407), 98 (396, 407), 99 (396, 333), 100 (354, 333), 101 (249, 333), 102 (141, 268), 103 (141, 203), 104 (141, 131), 105 (247, 65), 106 ], 107 {5, 15, 24}, 108 ), 109 ], 110 ) 111 def test_forced_set(self, delta, coords, forced): 112 f = iup._iup_contour_bound_forced_set(delta, coords) 113 assert forced == f 114 115 chain1, costs1 = iup._iup_contour_optimize_dp(delta, coords, f) 116 chain2, costs2 = iup._iup_contour_optimize_dp(delta, coords, set()) 117 118 assert chain1 == chain2, f 119 assert costs1 == costs2, f 120 121 122if __name__ == "__main__": 123 sys.exit(pytest.main(sys.argv)) 124