fix: Merge same-net trace lines that are close together (make at the same Y or same X) (#34)#344
Open
IbrahimLaeeq wants to merge 2 commits into
Open
fix: Merge same-net trace lines that are close together (make at the same Y or same X) (#34)#344IbrahimLaeeq wants to merge 2 commits into
IbrahimLaeeq wants to merge 2 commits into
Conversation
…same Y or same X) (tscircuit#34)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new trace-cleanup step that snaps parallel internal segments of same-net traces onto a shared coordinate when they are close enough, resolving the issue where same-net parallel lines remained slightly offset.
Changes:
- New
mergeSameNetCloseTracespure function that aligns nearby parallel same-net internal segments to their midpoint coordinate. - Inserts a new
"merging_same_net_traces"pipeline step intoTraceCleanupSolverbetween untangling and turn-minimization. - Adds unit tests covering merge, no-merge (different nets / too-far / endpoints / non-overlapping) scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/solvers/TraceCleanupSolver/mergeSameNetCloseTraces.ts | New helper that groups traces by net and snaps close parallel internal segments to a midpoint coord. |
| lib/solvers/TraceCleanupSolver/TraceCleanupSolver.ts | Adds the new pipeline step and wires it in after untangling. |
| tests/solvers/TraceCleanupSolver/mergeSameNetCloseTraces.test.ts | Unit tests verifying merge/no-merge behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e841f78 to
11873e8
Compare
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.
Fixes #34.
/claim #34
ine only shifted different-net traces apart (via
TraceOverlapShiftSolver); nothing pulled close same-net parallel segments together, so two traces on one net could leave the schematic as two near-parallel lines a small offset apart.Changes
lib/solvers/TraceCleanupSolver/mergeSameNetCloseTraces.ts(new): pure function that, for each global-conn-net, finds parallel internal segments from different traces whose perpendicular distance is below a small threshold (default0.15) and whose parallel ranges overlap, then snaps both to the midpoint coordinate. Only internal segments (pi ∈ [1, length-3]) are touched, so pin-anchored endpoints are never moved.lib/solvers/TraceCleanupSolver/TraceCleanupSolver.ts: adds a"merging_same_net_traces"step between the untangling and turn-minimization phases. It runs the new merge once, then proceeds to the existing minimize/balance phases (which will simplify any redundant geometry it leaves behind).tests/solvers/TraceCleanupSolver/mergeSameNetCloseTraces.test.ts(new): 6 cases covering horizontal merge, vertical merge, different-net no-op, too-far no-op, endpoint-only no-op, and non-overlapping no-op.Verification
bunx tsc --noEmitclean.bun test: 63 pass / 4 skip / 0 fail (was 57/4/0; the 6 new tests are the delta). All existing example snapshots are unchanged — the new step is a no-op on current fixtures and only activates when same-net parallel segments fall within the close-together threshold.Verified against the repository's own test suite before submission.