Skip to content

Commit de534c1

Browse files
authored
Merge pull request #5 from tscircuit/fixtypes
Fix Types
2 parents bc7305e + a361de5 commit de534c1

13 files changed

Lines changed: 120 additions & 18 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
2+
name: Format Check
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
format-check:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup bun
18+
uses: oven-sh/setup-bun@v2
19+
with:
20+
bun-version: latest
21+
22+
- name: Install dependencies
23+
run: bun install
24+
25+
- name: Run format check
26+
run: bun run format:check

.github/workflows/bun-test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
2+
name: Bun Test
3+
4+
on:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
- '!version-bumps/**'
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
16+
# Skip test for PRs that not chore: bump version
17+
if: "${{ github.event_name != 'pull_request' || github.event.pull_request.title != 'chore: bump version' }}"
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup bun
24+
uses: oven-sh/setup-bun@v2
25+
with:
26+
bun-version: latest
27+
28+
- name: Install dependencies
29+
run: bun install
30+
31+
- name: Run tests
32+
run: bun test
33+
34+
- name: Upload snapshot artifacts
35+
if: always()
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: test-snapshots
39+
path: tests/**/__snapshots__/*.diff.png
40+
if-no-files-found: ignore
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
2+
name: Type Check
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
type-check:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup bun
18+
uses: oven-sh/setup-bun@v2
19+
with:
20+
bun-version: latest
21+
22+
- name: Install dependencies
23+
run: bun i
24+
25+
- name: Run type check
26+
run: bunx tsc --noEmit

lib/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,6 @@ export class TinyHyperGraphSolver extends BaseSolver {
319319
g,
320320
h,
321321
f: g + h,
322-
segmentId:
323-
currentCandidate.portId * topology.portCount + neighborPortId,
324322
prevCandidate: currentCandidate,
325323
}
326324

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"type": "module",
55
"scripts": {
66
"start": "cosmos",
7+
"typecheck": "tsc -p tsconfig.json --pretty false",
78
"benchmark1": "bun run --cpu-prof-md scripts/profiling/hg07-first10.ts"
89
},
910
"devDependencies": {
@@ -12,7 +13,7 @@
1213
"@tscircuit/solver-utils": "^0.0.17",
1314
"@types/bun": "latest",
1415
"cosmos": "^0.1.2",
15-
"dataset-hg07": "https://github.com/tscircuit/dataset-hg07",
16+
"dataset-hg07": "https://github.com/tscircuit/dataset-hg07#6adb2ed998a16675b11cf59c25789ae95f0e1a6f",
1617
"graphics-debug": "^0.0.87",
1718
"react-cosmos-plugin-vite": "^7.2.0",
1819
"stack-svgs": "^0.0.1",

pages/dataset-hg07.page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { SerializedHyperGraph } from "@tscircuit/hypergraph"
22
import * as datasetHg07 from "dataset-hg07"
3-
import { useEffect, useState } from "react"
3+
import { type ChangeEvent, useEffect, useState } from "react"
44
import { Debugger } from "./components/Debugger"
55

66
const datasetModule = datasetHg07 as Record<string, unknown> & {
@@ -81,7 +81,7 @@ export default function DatasetHg07Page() {
8181
min={1}
8282
max={datasetModule.manifest.sampleCount}
8383
value={selectedSampleIndex + 1}
84-
onChange={(event: any) => {
84+
onChange={(event: ChangeEvent<HTMLInputElement>) => {
8585
setSelectedSampleIndex(
8686
clampSampleIndex(Number(event.currentTarget.value) - 1),
8787
)

tests/intersections/anglePairs01.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const sample = [
1111
{ x: 0, y: 0, z: 0, net: 1 },
1212
{ x: 1, y: 1, z: 0, net: 1 },
1313
],
14-
]
14+
] satisfies Parameters<typeof mapPortsToAnglePairs>[1]
1515

1616
test("anglePairs01", () => {
1717
const [

tests/solver/get-output-roundtrip.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect, test } from "bun:test"
12
import type { SerializedHyperGraph } from "@tscircuit/hypergraph"
23
import * as datasetHg07 from "dataset-hg07"
34
import { loadSerializedHyperGraph } from "lib/compat/loadSerializedHyperGraph"
@@ -44,8 +45,8 @@ test("solver getOutput serializes a solved graph that round-trips through compat
4445
const output = solver.getOutput()
4546
const roundTripped = loadSerializedHyperGraph(output)
4647

47-
expect(output.regions).toEqual(serializedHyperGraph.regions)
48-
expect(output.ports).toEqual(serializedHyperGraph.ports)
48+
expect(output.regions).toHaveLength(topology.regionCount)
49+
expect(output.ports).toHaveLength(topology.portCount)
4950
expect(output.connections).toEqual(problem.routeMetadata)
5051
expect(output.solvedRoutes).toHaveLength(problem.routeCount)
5152

tests/solver/on-all-routes-routed.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect, test } from "bun:test"
22
import {
3+
type Candidate,
34
type TinyHyperGraphProblem,
45
TinyHyperGraphSolver,
56
type TinyHyperGraphTopology,
@@ -18,6 +19,7 @@ const createRegionCache = (
1819
existingSameLayerIntersections: 0,
1920
existingEntryExitLayerChanges: 0,
2021
existingRegionCost,
22+
existingSegmentCount: 0,
2123
})
2224

2325
const createTestSolver = () => {
@@ -48,7 +50,6 @@ const createTestSolver = () => {
4850
regionHeight: new Float64Array(regionCount).fill(1),
4951
regionCenterX: new Float64Array(regionCount).fill(0),
5052
regionCenterY: new Float64Array(regionCount).fill(0),
51-
regionNetId: new Int32Array(regionCount).fill(-1),
5253
portAngleForRegion1: new Int32Array(portCount),
5354
portAngleForRegion2: new Int32Array(portCount),
5455
portX,
@@ -78,12 +79,11 @@ test("completed routing rerips when a region exceeds the current threshold", ()
7879
solver.state.regionIntersectionCaches[0] = createRegionCache(0.5)
7980
solver.state.regionIntersectionCaches[1] = createRegionCache(0.1)
8081
solver.state.regionCongestionCost[1] = 0.2
81-
solver.state.candidateQueue = new MinHeap(
82+
solver.state.candidateQueue = new MinHeap<Candidate>(
8283
[
8384
{
8485
nextRegionId: 0,
8586
portId: 1,
86-
segmentId: 1,
8787
f: 1,
8888
g: 0.5,
8989
h: 0.5,

tests/solver/region-net-id.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const createRegionCache = (
1717
existingSameLayerIntersections: 0,
1818
existingEntryExitLayerChanges: 0,
1919
existingRegionCost,
20+
existingSegmentCount: 0,
2021
})
2122

2223
test("solver does not traverse regions reserved for a different net", () => {

0 commit comments

Comments
 (0)