fastled 1.2.70__py3-none-any.whl → 1.2.73__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fastled/string_diff.py CHANGED
@@ -3,6 +3,24 @@ from pathlib import Path
3
3
  from rapidfuzz import fuzz
4
4
 
5
5
 
6
+ def _filter_out_obvious_bad_choices(
7
+ input_str: str, string_list: list[str]
8
+ ) -> list[str]:
9
+ """
10
+ Filter out strings that are too different from the input string.
11
+ This is a heuristic and may not be perfect.
12
+ """
13
+ input_chars = set(input_str)
14
+ filtered_list = []
15
+ for s in string_list:
16
+ # Check if at least half of the input characters are in the string
17
+ s_chars = set(s)
18
+ common_chars = input_chars.intersection(s_chars)
19
+ if len(common_chars) >= len(input_chars) / 2:
20
+ filtered_list.append(s)
21
+ return filtered_list
22
+
23
+
6
24
  # Returns the min distance strings. If there is a tie, it returns
7
25
  # all the strings that have the same min distance.
8
26
  # Returns a tuple of index and string.
@@ -24,6 +42,10 @@ def string_diff(
24
42
  string_list = [s.lower() for s in string_list]
25
43
  input_string = input_string.lower()
26
44
 
45
+ # Apply set membership filtering for queries with 3+ characters
46
+ if len(input_string) >= 3:
47
+ string_list = _filter_out_obvious_bad_choices(input_string, string_list)
48
+
27
49
  is_substring = False
28
50
  for s in string_list:
29
51
  if input_string in s: