Skip to content

Commit bf6a028

Browse files
authored
Update github actions (#701)
* Update github actions * Prevent some logs from being output during testing * Slightly improved testing
1 parent c6187d7 commit bf6a028

File tree

9 files changed

+36
-47
lines changed

9 files changed

+36
-47
lines changed

.github/workflows/gh-pages.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
test-lib:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v2
23-
- uses: actions/setup-node@v2
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-node@v4
2424
with:
25-
node-version: '16.x'
25+
node-version: 18
2626
- name: Install
2727
run: yarn
2828
- name: Prepare ONNX
@@ -36,17 +36,17 @@ jobs:
3636
test-gui:
3737
runs-on: ubuntu-latest
3838
steps:
39-
- uses: actions/checkout@v2
39+
- uses: actions/checkout@v4
4040
- name: Test GUI
4141
run: docker-compose run --rm test-gui --bail
4242
deploy:
4343
runs-on: ubuntu-latest
4444
needs: [test-lib, test-gui]
4545
steps:
46-
- uses: actions/checkout@v2
47-
- uses: actions/setup-node@v2
46+
- uses: actions/checkout@v4
47+
- uses: actions/setup-node@v4
4848
with:
49-
node-version: '16.x'
49+
node-version: 18
5050
- name: Install
5151
run: yarn
5252
- name: Build

.github/workflows/npm.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
10-
- uses: actions/setup-node@v2
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-node@v4
1111
with:
12-
node-version: '16.x'
12+
node-version: 18
1313
- name: Install
1414
run: yarn
1515
- name: Prepare ONNX
@@ -20,10 +20,10 @@ jobs:
2020
runs-on: ubuntu-latest
2121
needs: test
2222
steps:
23-
- uses: actions/checkout@v2
24-
- uses: actions/setup-node@v2
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-node@v4
2525
with:
26-
node-version: '16.x'
26+
node-version: 18
2727
registry-url: 'https://registry.npmjs.org'
2828
- name: Install
2929
run: yarn

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ jobs:
44
test-lib:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v2
8-
- uses: actions/setup-node@v2
7+
- uses: actions/checkout@v4
8+
- uses: actions/setup-node@v4
99
with:
10-
node-version: '16.x'
10+
node-version: 18
1111
- name: Install
1212
run: yarn
1313
- name: Prepare ONNX
@@ -21,6 +21,6 @@ jobs:
2121
test-gui:
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v4
2525
- name: Test GUI
2626
run: docker-compose run --rm test-gui --bail

js/renderer/document.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,28 @@ export default class DocumentScatterRenderer extends BaseRenderer {
8888

8989
const width = this.width
9090
const height = this.height - 20
91+
const range = [width, height]
9192

92-
const scales = [width, height].map((m, i) => (m - 10) / (y_max[i] - y_min[i]))
93+
const scales = range.map((m, i) => (m - 10) / (y_max[i] - y_min[i]))
9394
const scale_min = Math.min(...scales)
9495
const offsets = [5, 20]
9596
for (let i = 0; i < scales.length; i++) {
9697
if (scales[i] > scale_min) {
9798
if (!isFinite(scales[i])) {
98-
offsets[i] = [width, height][i] / 2 - y_min[i]
99+
offsets[i] = range[i] / 2 - y_min[i]
99100
} else {
100101
offsets[i] += ((scales[i] - scale_min) * (y_max[i] - y_min[i])) / 2
101102
}
102103
}
103104
}
104105
for (let i = 0; i < data.length; i++) {
105-
const v = data[i].map((a, k) => (a - y_min[k]) * scale_min + offsets[k])
106+
const v = data[i].map((a, k) => {
107+
const p = (a - y_min[k]) * scale_min + offsets[k]
108+
return isFinite(p) ? p : range[k] / 2
109+
})
106110
const text = document.createElementNS('http://www.w3.org/2000/svg', 'text')
107111
text.setAttribute('x', v[0])
108-
text.setAttribute('y', v[1])
112+
text.setAttribute('y', v[1] ?? range[1] / 2)
109113
text.innerHTML = words[i]
110114
const title = document.createElementNS('http://www.w3.org/2000/svg', 'title')
111115
title.innerHTML = words[i]

tests/lib/model/findit.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { jest } from '@jest/globals'
2+
jest.retryTimes(3)
3+
14
import Matrix from '../../../lib/util/matrix.js'
25
import FINDIT from '../../../lib/model/findit.js'
36

tests/lib/model/gbdt.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { rmse } from '../../../lib/evaluate/regression.js'
77
describe('classifier', () => {
88
test('default', () => {
99
const model = new GBDTClassifier()
10-
const x = Matrix.randn(20, 10).toArray()
10+
const x = Matrix.concat(Matrix.randn(10, 3, 0, 0.2), Matrix.randn(10, 3, 5, 0.2)).toArray()
1111
const t = []
1212
for (let i = 0; i < 20; i++) {
13-
t[i] = String.fromCharCode('a'.charCodeAt(0) + Math.floor(i / 5))
13+
t[i] = String.fromCharCode('a'.charCodeAt(0) + Math.floor(i / 10))
1414
}
1515
model.init(x, t)
1616
for (let i = 0; i < 20; i++) {
@@ -20,7 +20,7 @@ describe('classifier', () => {
2020
const y = model.predict(x)
2121
expect(y).toHaveLength(x.length)
2222
const acc = accuracy(y, t)
23-
expect(acc).toBeGreaterThan(0.6)
23+
expect(acc).toBeGreaterThan(0.9)
2424
})
2525

2626
test.each([0.5, 0])('classifier %d', lr => {

tests/lib/model/hdbscan.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('clustering', () => {
2525
t[i] = Math.floor(i / n)
2626
}
2727
const ri = randIndex(y, t)
28-
expect(ri).toBeGreaterThan(0.9)
28+
expect(ri).toBeGreaterThan(0.7)
2929
})
3030

3131
test.each([undefined, 'euclid', 'manhattan', 'chebyshev'])('%s', metric => {

tests/lib/model/projectron.test.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,7 @@ describe('projectron', () => {
5757

5858
test('kernel polynomial', () => {
5959
const model = new Projectron(0.1, 'polynomial')
60-
const s = 5
61-
const x = []
62-
for (let i = 0; i < 50; i++) {
63-
const r = (i / 50) * Math.PI
64-
x.push([Math.cos(r) * s + Math.random() - 0.5, Math.sin(r) * s + Math.random() - 0.5])
65-
}
66-
for (let i = 0; i < 50; i++) {
67-
const r = (i / 50) * Math.PI
68-
x.push([s - Math.cos(r) * s + Math.random() - 0.5, s - Math.sin(r) * s - s / 2 + Math.random() - 0.5])
69-
}
60+
const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray()
7061
const t = []
7162
for (let i = 0; i < x.length; i++) {
7263
t[i] = Math.floor(i / 50) * 2 - 1
@@ -146,16 +137,7 @@ describe('projectron++', () => {
146137

147138
test('kernel polynomial', () => {
148139
const model = new Projectronpp(0.1, 'polynomial')
149-
const s = 5
150-
const x = []
151-
for (let i = 0; i < 50; i++) {
152-
const r = (i / 50) * Math.PI
153-
x.push([Math.cos(r) * s + Math.random() - 0.5, Math.sin(r) * s + Math.random() - 0.5])
154-
}
155-
for (let i = 0; i < 50; i++) {
156-
const r = (i / 50) * Math.PI
157-
x.push([s - Math.cos(r) * s + Math.random() - 0.5, s - Math.sin(r) * s - s / 2 + Math.random() - 0.5])
158-
}
140+
const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray()
159141
const t = []
160142
for (let i = 0; i < x.length; i++) {
161143
t[i] = Math.floor(i / 50) * 2 - 1
@@ -165,7 +147,7 @@ describe('projectron++', () => {
165147
}
166148
const y = model.predict(x)
167149
const acc = accuracy(y, t)
168-
expect(acc).toBeGreaterThan(0.55)
150+
expect(acc).toBeGreaterThan(0.8)
169151
})
170152

171153
test('custom kernel', () => {

tests/lib/model/svc.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('clustering', () => {
5252
t[i] = Math.floor(i / n)
5353
}
5454
const ri = randIndex(y, t)
55-
expect(ri).toBeGreaterThan(0.7)
55+
expect(ri).toBeGreaterThan(0.6)
5656
})
5757

5858
test('custom kernel', () => {

0 commit comments

Comments
 (0)