Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/gui/view/diffusion_model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ describe('generate', () => {

await expect(epoch.textContent()).resolves.toBe('10')
await expect(methodFooter.textContent()).resolves.toMatch(/^loss/)
})
}, 60000)
})
42 changes: 21 additions & 21 deletions tests/gui/view/mds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ describe('dimensionality reduction', () => {
let page
beforeEach(async () => {
page = await getPage()
const clusters = page.locator('#data_menu input[name=n]')
await clusters.fill('1')
const resetDataButton = page.locator('#data_menu input[value=Reset]')
await resetDataButton.dispatchEvent('click')
const taskSelectBox = page.locator('#ml_selector dl:first-child dd:nth-child(5) select')
await taskSelectBox.selectOption('DR')
const modelSelectBox = page.locator('#ml_selector .model_selection #mlDisp')
await modelSelectBox.selectOption('mds')
})

afterEach(async () => {
await page?.close()
})

test('initialize', async () => {
const taskSelectBox = await page.waitForSelector('#ml_selector dl:first-child dd:nth-child(5) select')
await taskSelectBox.selectOption('DR')
const modelSelectBox = await page.waitForSelector('#ml_selector .model_selection #mlDisp')
await modelSelectBox.selectOption('mds')
const methodMenu = await page.waitForSelector('#ml_selector #method_menu')
const buttons = await methodMenu.waitForSelector('.buttons')
expect.assertions(0)
const methodMenu = page.locator('#ml_selector #method_menu')
const buttons = methodMenu.locator('.buttons')

const fitButton = await buttons.waitForSelector('input[value=Fit]')
expect(fitButton).toBeDefined()
const fitButton = buttons.locator('input[value=Fit]')
await fitButton.waitFor()
})

test('learn', async () => {
const taskSelectBox = await page.waitForSelector('#ml_selector dl:first-child dd:nth-child(5) select')
await taskSelectBox.selectOption('DR')
const modelSelectBox = await page.waitForSelector('#ml_selector .model_selection #mlDisp')
await modelSelectBox.selectOption('mds')
const methodMenu = await page.waitForSelector('#ml_selector #method_menu')
const buttons = await methodMenu.waitForSelector('.buttons')
const methodMenu = page.locator('#ml_selector #method_menu')
const buttons = methodMenu.locator('.buttons')

const fitButton = await buttons.waitForSelector('input[value=Fit]')
await fitButton.evaluate(el => el.click())
const fitButton = buttons.locator('input[value=Fit]')
await fitButton.dispatchEvent('click')

const svg = await page.waitForSelector('#plot-area svg')
await svg.waitForSelector('.tile circle')
const circles = await svg.$$('.tile circle')
expect(circles).toHaveLength(300)
}, 60000)
const svg = page.locator('#plot-area svg')
const circles = svg.locator('.tile circle')
await expect(circles.count()).resolves.toBe(100)
})
})
52 changes: 27 additions & 25 deletions tests/gui/view/word_to_vec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ describe('word embedding', () => {
let page
beforeEach(async () => {
page = await getPage()
const dataSelectBox = await page.waitForSelector('#ml_selector dl:first-child dd:nth-child(2) select')
const dataSelectBox = page.locator('#ml_selector dl:first-child dd:nth-child(2) select')
await dataSelectBox.selectOption('text')
const taskSelectBox = await page.waitForSelector('#ml_selector dl:first-child dd:nth-child(5) select')
const svg = page.locator('#plot-area svg')
await svg.locator('.points circle').waitFor()
const taskSelectBox = page.locator('#ml_selector dl:first-child dd:nth-child(5) select')
await taskSelectBox.selectOption('WE')
const modelSelectBox = await page.waitForSelector('#ml_selector .model_selection #mlDisp')
const modelSelectBox = page.locator('#ml_selector .model_selection #mlDisp')
await modelSelectBox.selectOption('word_to_vec')
})

Expand All @@ -21,35 +23,35 @@ describe('word embedding', () => {
})

test('initialize', async () => {
const methodMenu = await page.waitForSelector('#ml_selector #method_menu')
const buttons = await methodMenu.waitForSelector('.buttons')

const method = await buttons.waitForSelector('select:nth-of-type(1)')
await expect((await method.getProperty('value')).jsonValue()).resolves.toBe('CBOW')
const n = await buttons.waitForSelector('input:nth-of-type(1)')
await expect(n.getAttribute('value')).resolves.toBe('1')
const iteration = await buttons.waitForSelector('select:nth-of-type(2)')
await expect((await iteration.getProperty('value')).jsonValue()).resolves.toBe('1')
const rate = await buttons.waitForSelector('input:nth-of-type(3)')
await expect(rate.getAttribute('value')).resolves.toBe('0.001')
const batch = await buttons.waitForSelector('input:nth-of-type(4)')
await expect(batch.getAttribute('value')).resolves.toBe('10')
const methodMenu = page.locator('#ml_selector #method_menu')
const buttons = methodMenu.locator('.buttons')

const method = buttons.locator('select').first()
await expect(method.inputValue()).resolves.toBe('CBOW')
const n = buttons.locator('input:nth-of-type(1)')
await expect(n.inputValue()).resolves.toBe('1')
const iteration = buttons.locator('select').nth(1)
await expect(iteration.inputValue()).resolves.toBe('1')
const rate = buttons.locator('input:nth-of-type(3)')
await expect(rate.inputValue()).resolves.toBe('0.001')
const batch = buttons.locator('input:nth-of-type(4)')
await expect(batch.inputValue()).resolves.toBe('10')
})

test('learn', async () => {
const methodMenu = await page.waitForSelector('#ml_selector #method_menu')
const buttons = await methodMenu.waitForSelector('.buttons')
const methodMenu = page.locator('#ml_selector #method_menu')
const buttons = methodMenu.locator('.buttons')

const epoch = await buttons.waitForSelector('[name=epoch]')
const epoch = buttons.locator('[name=epoch]')
await expect(epoch.textContent()).resolves.toBe('0')
const methodFooter = await page.waitForSelector('#method_footer', { state: 'attached' })
const methodFooter = page.locator('#method_footer', { state: 'attached' })
await expect(methodFooter.textContent()).resolves.toBe('')

const initButton = await buttons.waitForSelector('input[value=Initialize]')
await initButton.evaluate(el => el.click())
const stepButton = await buttons.waitForSelector('input[value=Step]:enabled')
await stepButton.evaluate(el => el.click())
await buttons.waitForSelector('input[value=Step]:enabled')
const initButton = buttons.locator('input[value=Initialize]')
await initButton.dispatchEvent('click')
const stepButton = buttons.locator('input[value=Step]:enabled')
await stepButton.dispatchEvent('click')
await buttons.locator('input[value=Step]:enabled').waitFor()

await expect(epoch.textContent()).resolves.toBe('1')
await expect(methodFooter.textContent()).resolves.toMatch(/^loss/)
Expand Down
12 changes: 6 additions & 6 deletions tests/lib/model/gmm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ describe('regression', () => {

test('probability', () => {
const model = new GMR()
const x = [
[0, 0],
[1, 1],
]
const t = [[0], [1]]
const x = Matrix.randn(50, 2, 0, 5).toArray()
const t = []
for (let i = 0; i < x.length; i++) {
t[i] = [x[i][0] + x[i][1] + (Math.random() - 0.5) / 10]
}

model.add()
model.add()
Expand All @@ -127,7 +127,7 @@ describe('regression', () => {
[[0], [-1]]
)
for (let c = 0; c < 2; c++) {
expect(p[0][c]).toBeGreaterThan(p[1][c])
expect(p[0][c]).toBeGreaterThanOrEqual(p[1][c])
}
})
})
Expand Down
Loading