be more forgiving about checking index deltas

This commit is contained in:
xenofem 2024-02-07 23:59:35 -05:00
parent de01acabe5
commit 62bd4891f6

View file

@ -235,15 +235,17 @@ def complete_prefix_number_ordering(entries):
unified_indices = list(unified_indices) unified_indices = list(unified_indices)
unified_indices.sort() unified_indices.sort()
min_delta_by_level = {}
if len(unified_indices) > 1: if len(unified_indices) > 1:
for i in range(1, len(unified_indices)): for i in range(1, len(unified_indices)):
cur = unified_indices[i] cur = unified_indices[i]
prev = unified_indices[i-1] prev = unified_indices[i-1]
for level in range(min(len(cur), len(prev))): for level in range(min(len(cur), len(prev))):
if cur[level] != prev[level]: if cur[level] != prev[level]:
if cur[level] - prev[level] > 2: delta = cur[level] - prev[level]
min_delta_by_level[level] = min(min_delta_by_level.get(level, delta), delta)
if any(delta > 2 for delta in min_delta_by_level.values()):
return None return None
break
unified_indices.append(None) unified_indices.append(None)