8 return abs(unit
.topt(l1
-l2
))<epsilon
12 class NormpathTestCase(unittest
.TestCase
):
14 p
= path(moveto(0,0), lineto(1,0), moveto(2,0), lineto(3,0))
19 assert len(sp
)==2 and sp
[0] is None and isEqual(sp
[1].arclength(), 2)
22 assert len(sp
)==2 and isEqual(sp
[0].arclength(), 0.5) and isEqual(sp
[1].arclength(), 1.5)
25 assert len(sp
)==2 and isEqual(sp
[0].arclength(), 1) and isEqual(sp
[1].arclength(), 1)
28 assert len(sp
)==2 and isEqual(sp
[0].arclength(), 1.5) and isEqual(sp
[1].arclength(), 0.5)
31 assert len(sp
)==2 and isEqual(sp
[0].arclength(), 2) and sp
[1] is None
33 # two split parameters
34 sp
= np
.split([0, 0.5])
35 assert len(sp
)==3 and sp
[0] is None and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 1.5)
38 assert len(sp
)==3 and sp
[0] is None and isEqual(sp
[1].arclength(), 1) and isEqual(sp
[2].arclength(), 1)
40 sp
= np
.split([0, 1.5])
41 assert len(sp
)==3 and sp
[0] is None and isEqual(sp
[1].arclength(), 1.5) and isEqual(sp
[2].arclength(), 0.5)
44 assert len(sp
)==3 and sp
[0] is None and isEqual(sp
[1].arclength(), 2) and sp
[2] is None
46 sp
= np
.split([0.5, 1])
47 assert len(sp
)==3 and isEqual(sp
[0].arclength(), 0.5) and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 1)
49 sp
= np
.split([0.5, 1.5])
50 assert len(sp
)==3 and isEqual(sp
[0].arclength(), 0.5) and isEqual(sp
[1].arclength(), 1) and isEqual(sp
[2].arclength(), 0.5)
52 sp
= np
.split([0.5, 2])
53 assert len(sp
)==3 and isEqual(sp
[0].arclength(), 0.5) and isEqual(sp
[1].arclength(), 1.5) and sp
[2] is None
55 sp
= np
.split([1, 1.5])
56 assert len(sp
)==3 and isEqual(sp
[0].arclength(), 1) and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 0.5)
59 assert len(sp
)==3 and isEqual(sp
[0].arclength(), 1) and isEqual(sp
[1].arclength(), 1) and sp
[2] is None
61 sp
= np
.split([1.5, 2])
62 assert len(sp
)==3 and isEqual(sp
[0].arclength(), 1.5) and isEqual(sp
[1].arclength(), 0.5) and sp
[2] is None
64 # three split parameters
65 sp
= np
.split([0, 0.5, 1])
66 assert len(sp
)==4 and sp
[0] is None and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 0.5) and isEqual(sp
[3].arclength(), 1)
68 sp
= np
.split([0, 0.5, 1.5])
69 assert len(sp
)==4 and sp
[0] is None and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 1) and isEqual(sp
[3].arclength(), 0.5)
71 sp
= np
.split([0, 0.5, 2])
72 assert len(sp
)==4 and sp
[0] is None and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 1.5) and sp
[3] is None
74 sp
= np
.split([0, 1, 1.5])
75 assert len(sp
)==4 and sp
[0] is None and isEqual(sp
[1].arclength(), 1) and isEqual(sp
[2].arclength(), 0.5) and isEqual(sp
[3].arclength(), 0.5)
77 sp
= np
.split([0, 1, 2])
78 assert len(sp
)==4 and sp
[0] is None and isEqual(sp
[1].arclength(), 1) and isEqual(sp
[2].arclength(), 1) and sp
[3] is None
81 sp
= np
.split([0, 1.5, 2])
82 assert len(sp
)==4 and sp
[0] is None and isEqual(sp
[1].arclength(), 1.5) and isEqual(sp
[2].arclength(), 0.5) and sp
[3] is None
84 sp
= np
.split([0.5, 1, 1.5])
85 assert len(sp
)==4 and isEqual(sp
[0].arclength(), 0.5) and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 0.5) and isEqual(sp
[3].arclength(), 0.5)
87 sp
= np
.split([0.5, 1.5, 2])
88 assert len(sp
)==4 and isEqual(sp
[0].arclength(), 0.5) and isEqual(sp
[1].arclength(), 1) and isEqual(sp
[2].arclength(), 0.5) and sp
[3] is None
90 sp
= np
.split([1, 1.5, 2])
91 assert len(sp
)==4 and isEqual(sp
[0].arclength(), 1) and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 0.5) and sp
[3] is None
94 # four split parameters
95 sp
= np
.split([0, 0.5, 1, 1.5])
96 assert len(sp
)==5 and sp
[0] is None and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 0.5) and isEqual(sp
[3].arclength(), 0.5) and isEqual(sp
[4].arclength(), 0.5)
98 sp
= np
.split([0, 0.5, 1, 2])
99 assert len(sp
)==5 and sp
[0] is None and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 0.5) and isEqual(sp
[3].arclength(), 1) and sp
[4] is None
101 sp
= np
.split([0, 0.5, 1.5, 2])
102 assert len(sp
)==5 and sp
[0] is None and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 1) and isEqual(sp
[3].arclength(), 0.5) and sp
[4] is None
104 sp
= np
.split([0, 1, 1.5, 2])
105 assert len(sp
)==5 and sp
[0] is None and isEqual(sp
[1].arclength(), 1) and isEqual(sp
[2].arclength(), 0.5) and isEqual(sp
[3].arclength(), 0.5) and sp
[4] is None
107 sp
= np
.split([0.5, 1, 1.5, 2])
108 assert len(sp
)==5 and isEqual(sp
[0].arclength(), 0.5) and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 0.5) and isEqual(sp
[3].arclength(), 0.5) and sp
[4] is None
111 # five split parameters
112 sp
= np
.split([0, 0.5, 1, 1.5, 2])
113 assert len(sp
)==6 and sp
[0] is None and isEqual(sp
[1].arclength(), 0.5) and isEqual(sp
[2].arclength(), 0.5) and isEqual(sp
[3].arclength(), 0.5) and isEqual(sp
[4].arclength(), 0.5) and sp
[5] is None
116 suite
= unittest
.TestSuite((unittest
.makeSuite(NormpathTestCase
, 'test'),))
118 if __name__
== "__main__":
119 runner
= unittest
.TextTestRunner()