fix: displace_symbol regex group count#11
Merged
Conversation
The displace_at callback referenced m.group(4) but the regex
defines only 3 capture groups (prefix, x, tail). IndexError
killed scale-up runs (--max-projects 30 hit this on a leaf
schematic that did have a matchable (symbol (at x y a)) block).
Fix: collapse y + angle into the 3rd group, format as
f\"{pre}{x + 500}{tail}\". Adjusted regex closing paren so the
tail group includes the closing ).
Scale-up validated: 28 triplets across 60 intact projects:
permissive: 19 (truncate_tail x14 + drop_global_label x5)
copyleft: 9 (truncate_tail x8 + drop_global_label x1)
There was a problem hiding this comment.
Pull request overview
Fixes a runtime failure in the KiCad D2 combined dataset builder’s displace_symbol noise injection by aligning the displace_at callback with the actual regex capture groups, preventing IndexError: no such group from aborting scale-up runs.
Changes:
- Adjusted the
displace_symbolsubstitution to use the correct capture groups (prefix, x, tail) and rebuild the(at ...)clause without referencing a non-existent group. - Updated the regex so the “tail” capture includes the closing
)needed by the replacement formatting. - Added an explanatory comment documenting the intended capture-group structure.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| y = m.group(3) | ||
| angle = m.group(4) | ||
| return f"{pre}(at {x + 500} {y} {angle})" | ||
| tail = m.group(3) # contains " y angle" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Quick fix:
displace_atcallback referencedm.group(4)but the regex defines only 3 capture groups.IndexError: no such groupkilled scale-up runs.Fix
Collapsed y + angle into the 3rd group, format as
f"{pre}{x+500}{tail}".Scale-up validated
--max-projects 30 --skip-prose→ 28 triplets across 60 intact projects:Pipeline E2E now stable. Closes tasks #2, #3, #5 (verified end-to-end).