MCPcopy Index your code
hub / github.com/ipython/ipython / recompute_unicode_ranges

Function recompute_unicode_ranges

tests/test_completer.py:59–97  ·  view source on GitHub ↗

utility to recompute the largest unicode range without any characters use to recompute the gap in the global _UNICODE_RANGES of completer.py

()

Source from the content-addressed store, hash-verified

57
58
59def recompute_unicode_ranges():
60 """
61 utility to recompute the largest unicode range without any characters
62
63 use to recompute the gap in the global _UNICODE_RANGES of completer.py
64 """
65 import itertools
66 import unicodedata
67
68 valid = []
69 for c in range(0, 0x10FFFF + 1):
70 try:
71 unicodedata.name(chr(c))
72 except ValueError:
73 continue
74 valid.append(c)
75
76 def ranges(i):
77 for a, b in itertools.groupby(enumerate(i), lambda pair: pair[1] - pair[0]):
78 b = list(b)
79 yield b[0][1], b[-1][1]
80
81 rg = list(ranges(valid))
82 lens = []
83 gap_lens = []
84 _pstart, pstop = 0, 0
85 for start, stop in rg:
86 lens.append(stop - start)
87 gap_lens.append(
88 (
89 start - pstop,
90 hex(pstop + 1),
91 hex(start),
92 f"{round((start - pstop)/0xe01f0*100)}%",
93 )
94 )
95 _pstart, pstop = start, stop
96
97 return sorted(gap_lens)[-1]
98
99
100def test_unicode_range():

Callers 1

test_unicode_rangeFunction · 0.85

Calls 2

rangesFunction · 0.85
nameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…