@tscircuit/schematic-trace-solver 0.0.161 → 0.0.163

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.
@@ -0,0 +1,21 @@
1
+ import { expect, test } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import type { InputProblem } from "lib/types/InputProblem"
4
+ import "tests/fixtures/matcher"
5
+ import inputProblemJson from "./assets/repro-isolated-rs485-isow7841.input.json"
6
+
7
+ test("repro isolated RS-485 ISOW7841 schematic traces", () => {
8
+ const inputProblem: InputProblem = JSON.parse(
9
+ JSON.stringify(inputProblemJson),
10
+ )
11
+ const solver = new SchematicTracePipelineSolver(inputProblem)
12
+
13
+ solver.solve()
14
+
15
+ expect(solver.solved).toBe(true)
16
+ expect(solver.schematicTraceLinesSolver?.solvedTracePaths).toHaveLength(50)
17
+ expect(solver.schematicTraceLinesSolver?.failedConnectionPairs).toHaveLength(
18
+ 0,
19
+ )
20
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
21
+ })
@@ -0,0 +1,73 @@
1
+ import { expect, test } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import type { InputProblem } from "lib/types/InputProblem"
4
+ import "tests/fixtures/matcher"
5
+
6
+ const inputProblem: InputProblem = {
7
+ chips: [
8
+ {
9
+ chipId: "R8",
10
+ center: { x: -7, y: -19 },
11
+ width: 0.6,
12
+ height: 0.65,
13
+ pins: [
14
+ { pinId: "R8.pin1", x: -7.3, y: -19, _facingDirection: "x-" },
15
+ { pinId: "R8.pin2", x: -6.7, y: -19, _facingDirection: "x+" },
16
+ ],
17
+ },
18
+ {
19
+ chipId: "R7",
20
+ center: { x: -5, y: -19 },
21
+ width: 0.6,
22
+ height: 0.65,
23
+ pins: [
24
+ { pinId: "R7.pin1", x: -5.3, y: -19, _facingDirection: "x-" },
25
+ { pinId: "R7.pin2", x: -4.7, y: -19, _facingDirection: "x+" },
26
+ ],
27
+ },
28
+ ],
29
+ directConnections: [],
30
+ netConnections: [
31
+ {
32
+ netId: "V3V3",
33
+ netLabelText: "V3V3",
34
+ pinIds: ["R8.pin2", "R7.pin2"],
35
+ netLabelWidth: 0.48,
36
+ netLabelHeight: 0.42,
37
+ },
38
+ {
39
+ netId: "U1_IO22",
40
+ netLabelText: "U1_IO22",
41
+ pinIds: ["R8.pin1"],
42
+ netLabelWidth: 0.84,
43
+ netLabelHeight: 0.42,
44
+ },
45
+ {
46
+ netId: "U1_IO21",
47
+ netLabelText: "U1_IO21",
48
+ pinIds: ["R7.pin1"],
49
+ netLabelWidth: 1,
50
+ netLabelHeight: 0.42,
51
+ },
52
+ ],
53
+ availableNetLabelOrientations: {
54
+ V3V3: ["y+"],
55
+ U1_IO22: ["x-"],
56
+ U1_IO21: ["x-"],
57
+ },
58
+ maxMspPairDistance: 2.4,
59
+ }
60
+
61
+ test("repro: V3V3 net-label branch does not start at the R8 edge", () => {
62
+ const solver = new SchematicTracePipelineSolver(inputProblem)
63
+
64
+ solver.solve()
65
+
66
+ expect(
67
+ solver.netLabelNetLabelCollisionSolver!.getOutput().netLabelPlacements,
68
+ ).not.toHaveLength(0)
69
+ expect(
70
+ solver.inlineNetLabelSolver!.getOutput().inlineNetLabelPlacements,
71
+ ).toHaveLength(0)
72
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
73
+ })
@@ -0,0 +1,57 @@
1
+ import { expect, test } from "bun:test"
2
+ import { MspConnectionPairSolver } from "lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver"
3
+ import type { InputNetConnection, InputProblem } from "lib/types/InputProblem"
4
+ import inputProblemJson from "../../repros/assets/repro-bluetooth-controller-ground-decoupling-groups.input.json"
5
+
6
+ function solveNetPairs({
7
+ inputProblem,
8
+ netConnection,
9
+ }: {
10
+ inputProblem: InputProblem
11
+ netConnection: InputNetConnection
12
+ }) {
13
+ const netPinIds = new Set(netConnection.pinIds)
14
+ const solver = new MspConnectionPairSolver({ inputProblem })
15
+
16
+ solver.solve()
17
+
18
+ return solver.mspConnectionPairs.filter((pair) =>
19
+ pair.pins.every((pin) => netPinIds.has(pin.pinId)),
20
+ )
21
+ }
22
+
23
+ test("keeps grouped ground rails in separate rows", () => {
24
+ const inputProblem = inputProblemJson as InputProblem
25
+ const groundConnection = inputProblem.netConnections.find(
26
+ (connection) => connection.isGround,
27
+ )!
28
+ const groundPairs = solveNetPairs({
29
+ inputProblem,
30
+ netConnection: groundConnection,
31
+ })
32
+ const crossRowPairs = groundPairs.filter(
33
+ (pair) => pair.pins[0].y !== pair.pins[1].y,
34
+ )
35
+
36
+ expect(groundPairs).toHaveLength(5)
37
+ expect(crossRowPairs).toHaveLength(0)
38
+ })
39
+
40
+ test("does not separate rows without ground metadata", () => {
41
+ const inputProblem = structuredClone(inputProblemJson) as InputProblem
42
+ const groundConnection = inputProblem.netConnections.find(
43
+ (connection) => connection.isGround,
44
+ )!
45
+ groundConnection.isGround = false
46
+
47
+ const netPairs = solveNetPairs({
48
+ inputProblem,
49
+ netConnection: groundConnection,
50
+ })
51
+ const crossRowPairs = netPairs.filter(
52
+ (pair) => pair.pins[0].y !== pair.pins[1].y,
53
+ )
54
+
55
+ expect(netPairs).toHaveLength(6)
56
+ expect(crossRowPairs).toHaveLength(1)
57
+ })