Lines Matching +full:test +full:- +full:cython
2 import cython
4 COMPILED = cython.compiled
6 # if cython not installed, use mock module with no-op decorators and types
7 from fontTools.misc import cython
31 @cython.cfunc
32 @cython.locals(
33 j=cython.int,
34 n=cython.int,
35 x1=cython.double,
36 x2=cython.double,
37 d1=cython.double,
38 d2=cython.double,
39 scale=cython.double,
40 x=cython.double,
41 d=cython.double,
45 ): # -> _DeltaSegment:
70 scale = (d2 - d1) / (x2 - x1)
80 d = d1 + (x - x1) * scale
87 def iup_contour(deltas: _DeltaOrNoneSegment, coords: _PointSegment) -> _DeltaSegment:
91 Returns fully filled-out delta vector."""
109 i1, i2, ri1, ri2 = 0, start, start, indices[-1]
117 if end - start > 1:
126 if start != n - 1:
141 ) -> _DeltaSegment:
146 Returns fully filled-out delta vector."""
148 assert sorted(ends) == ends and len(coords) == (ends[-1] + 1 if ends else 0) + 4
150 ends = ends + [n - 4, n - 3, n - 2, n - 1]
165 @cython.cfunc
166 @cython.inline
167 @cython.locals(
168 i=cython.int,
169 j=cython.int,
170 # tolerance=cython.double, # https://github.com/fonttools/fonttools/issues/3282
171 x=cython.double,
172 y=cython.double,
173 p=cython.double,
174 q=cython.double,
176 @cython.returns(int)
183 ): # -> bool:
188 assert j - i >= 2
193 abs(complex(x - p, y - q)) <= tolerance
198 @cython.locals(
199 cj=cython.double,
200 dj=cython.double,
201 lcj=cython.double,
202 ldj=cython.double,
203 ncj=cython.double,
204 ndj=cython.double,
205 force=cython.int,
210 ) -> set:
213 speeding up the dynamic-programming, as well as resolve circularity in DP.
223 for i in range(len(deltas) - 1, -1, -1):
224 ld, lc = deltas[i - 1], coords[i - 1]
226 nd, nc = deltas[i - n + 1], coords[i - n + 1]
249 # This test has to be before the next one.
251 if abs(d1 - d2) > tolerance and abs(dj) > tolerance:
257 # allowance), then there is no way that current point can be IUP-ed.
260 if not (min(d1, d2) - tolerance <= dj <= max(d1, d2) + tolerance):
270 and abs(dj - d1) > tolerance
271 and ((dj - tolerance < d1) != (d1 < d2))
277 and abs(dj - d2) > tolerance
289 @cython.locals(
290 i=cython.int,
291 j=cython.int,
292 best_cost=cython.double,
293 best_j=cython.int,
294 cost=cython.double,
296 tolerance=cython.double,
305 """Straightforward Dynamic-Programming. For each index i, find least-costly encoding of
309 Note that solution always encodes last point explicitly. Higher-level is responsible
318 costs = {-1: 0}
319 chain = {-1: None}
321 best_cost = costs[i - 1] + 1
324 chain[i] = i - 1
326 if i - 1 in forced:
329 for j in range(i - 2, max(i - lookback, -2), -1):
349 return l[n - k :] + l[: n - k]
361 ) -> _DeltaOrNoneSegment:
384 return [d0] + [None] * (n - 1)
392 # whether forced set is non-empty or not:
395 # if the font size changes (reduced); that would mean the forced-set
398 # Forced set is non-empty: rotate the contour start point
400 k = (n - 1) - max(forced)
408 # to exercise forced-set computation for under-counting.
413 i = n - 1
417 solution.remove(-1)
427 deltas = _rot_list(deltas, -k)
430 # circular n-length problem in the solution for new linear case. I cannot prove that
437 for start in range(n - 1, len(costs) - 1):
441 while i > start - n:
444 if i == start - n:
445 cost = costs[start] - costs[start - n]
465 ) -> _DeltaOrNoneSegment:
473 assert sorted(ends) == ends and len(coords) == (ends[-1] + 1 if ends else 0) + 4
475 ends = ends + [n - 4, n - 3, n - 2, n - 1]
482 assert len(contour) == end - start + 1