Skip to content

Commit d10c943

Browse files
committed
copilot comments
1 parent 0b57c5a commit d10c943

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/identifiers/diagram.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def identify_diagram(ctx: PageContext, matching_params: dict, axis_tolerance: in
3333
- Otherwise, attempts to detect both x- and y-axes by clustering numbers based on their positions
3434
- Returns True if both axes appear to be ordered scales, or if at least one axis shows numeric progression.
3535
"""
36-
keywords = (matching_params.get("diagram", {}) or {}).get(ctx.language, []) or []
36+
keywords = matching_params.get("diagram", {}).get(ctx.language, [])
3737
units_cfg = matching_params.get("units", [])
3838

39-
words_lower = (word.text.lower() for word in ctx.words)
39+
words_lower = [word.text.lower() for word in ctx.words]
4040
has_keyword = any(key in word for word in words_lower for key in keywords)
4141
has_unit = has_units(ctx, units_cfg)
4242

@@ -84,7 +84,7 @@ def axis_checks(clusters: list, sort_key: Callable) -> tuple[bool, bool]:
8484
return any_monotone, any_progression
8585

8686

87-
def normalize_direction(values: list[Entry]) -> list:
87+
def normalize_direction(values: list[Entry]) -> list[Entry]:
8888
"""Ensure values of entries go ascending; reverse if descending, leave otherwise."""
8989
if len(values) < 2:
9090
return values
@@ -108,7 +108,7 @@ def is_arithmetic_progression(
108108
109109
values: values of the potential arithmetic progression.
110110
frac_ok: fraction of steps that must match the median (e.g. 0.8 allows some OCR noise).
111-
abs_tol: minimum absolute tolerance so small steps survive rounding/jitter. .
111+
abs_tol: minimum absolute tolerance so small steps survive rounding/jitter.
112112
"""
113113
if len(values) <= 2:
114114
return False
@@ -124,7 +124,7 @@ def is_arithmetic_progression(
124124

125125
def is_log_progression(values: list, tol: float = 0.1) -> bool:
126126
"""Checks if values are a log10 based progression."""
127-
if any(v <= 0 for v in values) or len(values) <= 2: ## log never negative
127+
if any(v <= 0 for v in values) or len(values) <= 2: # log requires positive values
128128
return False
129129
log_vals = [math.log10(v) for v in values]
130130
diffs = [b - a for a, b in zip(log_vals, log_vals[1:], strict=False)]

0 commit comments

Comments
 (0)