From 194c66aa36bfe640ca180982498f29f2999eee23 Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Mon, 26 Jul 2021 09:46:37 -0400 Subject: [PATCH] lint checks --- m.js | 12 ++++---- m.test.js | 90 ++++++++++++++++++++++++------------------------------- 2 files changed, 45 insertions(+), 57 deletions(-) diff --git a/m.js b/m.js index 1a85dac..37a74e5 100644 --- a/m.js +++ b/m.js @@ -4,14 +4,14 @@ const M = { Loop: (inDimensions, inCount, inFunction)=> { - let row, i, outputCloud, outputVector; - outputCloud = []; - for(row=0; row M.Iterate.Loop(inV1.length, inCount, (i, row)=> inV1[i]+(inV2[i]-inV1[i])*Math.random()), + Box: (inV1, inV2, inCount)=> M.Iterate.Loop(inV1.length, inCount, i=> inV1[i]+(inV2[i]-inV1[i])*Math.random()), Transpose: (inCloud)=> M.Iterate.Loop(inCloud.length, inCloud[0].length, (i, row)=> inCloud[i][row]), Outer: (inV1, inV2)=> M.Iterate.Loop(inV1.length, inV2.length, (i, row)=> inV1[i]*inV2[row]), Clone: (inCloud)=> M.Iterate.Edit(inCloud, i=> i) diff --git a/m.test.js b/m.test.js index 2bbab28..77381c9 100644 --- a/m.test.js +++ b/m.test.js @@ -3,9 +3,9 @@ import { default as M } from "./m.js"; Deno.test("Iterate.Loop", ()=> { - let dimensions = 3; - let count = 4; - let cloud = M.Iterate.Loop(dimensions, count, (i, j)=>i+j); + const dimensions = 3; + const count = 4; + const cloud = M.Iterate.Loop(dimensions, count, (i, j)=>i+j); assertEquals(cloud.length, count, "correct count"); assertEquals(cloud[0].length, dimensions, "correct dimensions"); assertEquals(cloud[0][0], 0); @@ -13,21 +13,20 @@ Deno.test("Iterate.Loop", ()=> }); Deno.test("Iterate.Edit", ()=> { - let c = [[1, 2], [3, 4]] - let t = M.Iterate.Edit(c, (i)=>i); + const c = [[1, 2], [3, 4]] + const t = M.Iterate.Edit(c, (i)=>i); assertEquals(t.length, c.length, "correct count"); assertEquals(t[0][0], c[0][0], "correct dimensions"); assertEquals(t[1][1], c[1][1], "correct placement"); }); - Deno.test("Create.Box", ()=> { - let min = [-1, -2, -3]; - let max = [1, 2, 3]; - let count = 10; + const min = [-1, -2, -3]; + const max = [1, 2, 3]; + const count = 10; - let box = M.Create.Box(min, max, count); + const box = M.Create.Box(min, max, count); assertEquals(box.length, count, "correct count"); for(let i=0; i }); Deno.test("Create.Transpose", ()=> { - let v1 = [1, 2, 3]; - let v2 = [4, 5, 6]; - let tpose = M.Create.Transpose([v1, v2]); + const v1 = [1, 2, 3]; + const v2 = [4, 5, 6]; + const tpose = M.Create.Transpose([v1, v2]); assertEquals(tpose.length, 3, "correct count"); assertEquals(tpose[0].length, 2, "correct dimensions"); assertEquals(tpose[0][0], v1[0]); @@ -51,27 +50,26 @@ Deno.test("Create.Transpose", ()=> }); Deno.test("Create.Outer", ()=> { - let v1 = [1, 2, 3]; - let v2 = [4, 5]; - let outer = M.Create.Outer(v1, v2); + const v1 = [1, 2, 3]; + const v2 = [4, 5]; + const outer = M.Create.Outer(v1, v2); assertEquals(outer.length, v2.length, "correct count"); assertEquals(outer[0].length, v1.length, "correct dimensions"); assertEquals(outer[1][0], v1[0]*v2[1], "correct placement") }); Deno.test("Create.Clone", ()=> { - let v1 = [1, 2, 3]; - let v2 = [4, 5, 6]; - let clone = M.Create.Clone([v1, v2]); + const v1 = [1, 2, 3]; + const v2 = [4, 5, 6]; + const clone = M.Create.Clone([v1, v2]); assertEquals(clone.length, 2, "correct count"); assertEquals(clone[0].length, v1.length, "correct dimensions"); assertEquals(clone[1][0], v2[0], "correct placement"); }); - Deno.test("Mutate.Pad", ()=> { - let matrix = [ + const matrix = [ [1, 2, 3], [4, 5, 6] ]; @@ -80,10 +78,9 @@ Deno.test("Mutate.Pad", ()=> assertEquals(matrix[0].length, 4, "correct dimensions"); assertEquals(matrix[0][3], 1, "correct placement"); }); - Deno.test("Mutate.Unpad", ()=> { - let matrix = [ + const matrix = [ [1, 2, 3, 1], [4, 5, 6, 1] ]; @@ -95,63 +92,54 @@ Deno.test("Mutate.Unpad", ()=> Deno.test("Single.Affine", ()=> { - let v = [1, 2]; - let m = [[0.1, 0.2], [0.3, 0.4]]; - let t = M.Single.Affine(v, m); + const v = [1, 2]; + const m = [[0.1, 0.2], [0.3, 0.4]]; + const t = M.Single.Affine(v, m); assertEquals(t.length, 2, "correct dimensions"); assertEquals(t[0], 0.5) assertEquals(t[1], 1.1, "correct placement"); }); - Deno.test("Single.Subtract", ()=> { - let v1 = [1, 2]; - let v2 = [3, 4]; - let t = M.Single.Subtract(v1, v2); + const v1 = [1, 2]; + const v2 = [3, 4]; + const t = M.Single.Subtract(v1, v2); assertEquals(t.length, 2, "correct dimensions"); assertEquals(t[0], -2) assertEquals(t[1], -2, "correct placement"); }); - Deno.test("Single.Multiply", ()=> { - let v1 = [1, 2]; - let v2 = [3, 4]; - let t = M.Single.Multiply(v1, v2); + const v1 = [1, 2]; + const v2 = [3, 4]; + const t = M.Single.Multiply(v1, v2); assertEquals(t.length, 2, "correct dimensions"); assertEquals(t[0], 3) assertEquals(t[1], 8, "correct placement"); }); - - Deno.test("Batch.Affine", ()=> { - let c = [[1, 2], [3, 4]]; - let m = [[0.1, 0.2], [0.3, 0.4]]; - let t = M.Batch.Affine(c, m); + const c = [[1, 2], [3, 4]]; + const m = [[0.1, 0.2], [0.3, 0.4]]; + const t = M.Batch.Affine(c, m); assertEquals(t.length, 2, "correct count"); assertEquals(t[0].length, 2, "correct dimensions") assertEquals(t[0][1], 1.1, "correct placement"); }); - Deno.test("Batch.Scale", ()=> { - let c = [[1, 2], [3, 4]]; - let s = 0.5; - let t = M.Batch.Scale(c, s); - console.log(t); + const c = [[1, 2], [3, 4]]; + const s = 0.5; + const t = M.Batch.Scale(c, s); assertEquals(t.length, 2, "correct count"); assertEquals(t[0].length, 2, "correct dimensions"); assertEquals(t[1][0], 1.5, "correct placement"); }); - - Deno.test("Batch.Sigmoid", ()=> { - let m = [[-1000, 1000]]; - let t = M.Batch.Sigmoid(m); - console.log(t); + const m = [[-1000, 1000]]; + const t = M.Batch.Sigmoid(m); assertEquals(t.length, 1, "correct count"); assertEquals(t[0].length, 2, "correct dimensions"); assert(t[0][0]>=0 && t[0][0]<0.5); @@ -159,8 +147,8 @@ Deno.test("Batch.Sigmoid", ()=> }); Deno.test("Batch.Derivative", ()=> { - let m = [[-1000, 0, 1000]]; - let t = M.Batch.Derivative(M.Batch.Sigmoid(m)); + const m = [[-1000, 0, 1000]]; + const t = M.Batch.Derivative(M.Batch.Sigmoid(m)); assertEquals(t.length, 1, "correct count"); assertEquals(t[0].length, 3, "correct dimensions"); assert(t[0][0]t[0][2]);