fix: add net label orientation solver and validation tests#27
Open
Bilal-Lodhi wants to merge 5 commits into
Open
fix: add net label orientation solver and validation tests#27Bilal-Lodhi wants to merge 5 commits into
Bilal-Lodhi wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new schematic-placement validation step that detects net labels whose computed orientation falls outside a readable landscape range (intended [-90°, 90°]), and surfaces those as placement issues with a proposed normalized angle.
Changes:
- Introduced
NetLabelOrientationSolverand registered it inSchematicPlacementPipeline. - Added
NetLabelOrientationUnreadableto the placement issue union and wired string rendering intoSchematicPlacementAnalysis. - Added a new Bun unit test covering a flagged vs unflagged net label orientation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
tests/cases/net-label-orientation.test.ts |
Adds a test case asserting a net label orientation issue and its string formatting. |
lib/types.ts |
Introduces NetLabelOrientationUnreadable and adds it to SchematicPlacementIssue. |
lib/solvers/SchematicPlacementPipeline/SchematicPlacementPipeline.ts |
Registers the new solver step in the analysis pipeline. |
lib/solvers/NetLabelOrientationSolver/NetLabelOrientationSolver.ts |
Implements angle computation, unreadable detection, normalization, and issue stringification. |
lib/analyze-schematic-placement.ts |
Routes the new issue type to the solver’s issueToString for analysis.toString(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+77
to
+78
| private normalizeAngle(angleDeg: number): number { | ||
| return ((angleDeg + 90) % 180) - 90 |
Comment on lines
+69
to
+71
| private computeAngleDeg(center: { x: number; y: number }, anchor: { x: number; y: number }): number { | ||
| return Math.atan2(anchor.y - center.y, anchor.x - center.x) * (180 / Math.PI) | ||
| } |
| lineItemType: "NetLabelOrientationUnreadable" | ||
| schematicNetLabelId: string | ||
| text: string | ||
| anchorSide: "top" | "bottom" | "left" | "right" |
| @@ -0,0 +1,53 @@ | |||
| // Run: bun test tests/cases/net-label-orientation.test.ts | |||
| import { expect, test } from "bun:test" | |||
| import { analyzeSchematicPlacement } from "../../lib/index" | |||
| } | ||
|
|
||
| private normalizeAngle(angleDeg: number): number { | ||
| return ((angleDeg + 90) % 180) - 90 |
| lineItemType: "NetLabelOrientationUnreadable" | ||
| schematicNetLabelId: string | ||
| text: string | ||
| anchorSide: "top" | "bottom" | "left" | "right" |
| @@ -0,0 +1,63 @@ | |||
| // Run: bun test tests/cases/net-label-orientation.test.ts | |||
| import { expect, test } from "bun:test" | |||
| import { analyzeSchematicPlacement } from "../../lib/index" | |||
Comment on lines
+39
to
+56
| test("detects unreadable net label orientation", () => { | ||
| const analysis = analyzeSchematicPlacement(netLabelUpsideDownCircuitJson) | ||
| const issuesLineItem = analysis | ||
| .getLineItems() | ||
| .find((lineItem) => lineItem.lineItemType === "SchematicPlacementIssues") | ||
|
|
||
| expect(issuesLineItem).toMatchObject({ | ||
| lineItemType: "SchematicPlacementIssues", | ||
| issues: [ | ||
| { | ||
| lineItemType: "NetLabelOrientationUnreadable", | ||
| text: "GND", | ||
| anchorSide: "left", | ||
| currentAngleDeg: 135, | ||
| normalizedAngleDeg: -45, | ||
| }, | ||
| ], | ||
| }) |
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.
Description
Addresses #23 by checking and normalizing the text angle of
schematic_net_labelelements.Changes
NetLabelOrientationSolverto check if net labels fall outside a readable landscape window ([-90°, 90°]).((angle + 90) % 180) - 90).SchematicPlacementPipeline.NetLabelOrientationUnreadabletypes and string conversion utilities.tests/cases/net-label-orientation.test.tsevaluating both flagged (135°) and unflagged (-45°) orientations.