Skip to content

Commit 074413e

Browse files
authored
test: Bump prettier and fix lint errors (#561)
1 parent 0697cb7 commit 074413e

11 files changed

Lines changed: 141 additions & 130 deletions

test/binomial_distribution.test.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,31 @@ test("binomialDistribution", function (t) {
5353
}
5454
);
5555

56-
t.test("can return null when p or n are not valid parameters", function (
57-
t
58-
) {
59-
t.equal(
60-
ss.binomialDistribution(0, 0.5),
61-
undefined,
62-
"n should be strictly positive"
63-
);
64-
t.equal(
65-
ss.binomialDistribution(1.5, 0.5),
66-
undefined,
67-
"n should be an integer"
68-
);
69-
t.equal(
70-
ss.binomialDistribution(2, -0.01),
71-
undefined,
72-
"p should be greater than 0.0"
73-
);
74-
t.equal(
75-
ss.binomialDistribution(2, 1.5),
76-
undefined,
77-
"p should be less than 1.0"
78-
);
79-
t.end();
80-
});
56+
t.test(
57+
"can return null when p or n are not valid parameters",
58+
function (t) {
59+
t.equal(
60+
ss.binomialDistribution(0, 0.5),
61+
undefined,
62+
"n should be strictly positive"
63+
);
64+
t.equal(
65+
ss.binomialDistribution(1.5, 0.5),
66+
undefined,
67+
"n should be an integer"
68+
);
69+
t.equal(
70+
ss.binomialDistribution(2, -0.01),
71+
undefined,
72+
"p should be greater than 0.0"
73+
);
74+
t.equal(
75+
ss.binomialDistribution(2, 1.5),
76+
undefined,
77+
"p should be less than 1.0"
78+
);
79+
t.end();
80+
}
81+
);
8182
t.end();
8283
});

test/coefficient_of_variation.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ function rnd(x) {
88
}
99

1010
test("coefficient_of_variation", function (t) {
11-
t.test("can get the coefficientOfVariation of a six-sided die", function (
12-
t
13-
) {
14-
t.equal(rnd(ss.coefficientOfVariation([1, 2, 3, 4])), 0.516);
15-
t.end();
16-
});
11+
t.test(
12+
"can get the coefficientOfVariation of a six-sided die",
13+
function (t) {
14+
t.equal(rnd(ss.coefficientOfVariation([1, 2, 3, 4])), 0.516);
15+
t.end();
16+
}
17+
);
1718

1819
t.end();
1920
});

test/combinations.test.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ test("combinations", function (t) {
88
t.deepEqual(ss.combinations([1], 1), [[1]]);
99
t.end();
1010
});
11-
t.test("generates combinations of 1,2,3 choosing two at a time", function (
12-
t
13-
) {
14-
t.deepEqual(ss.combinations([1, 2, 3], 2), [
15-
[1, 2],
16-
[1, 3],
17-
[2, 3]
18-
]);
19-
t.end();
20-
});
11+
t.test(
12+
"generates combinations of 1,2,3 choosing two at a time",
13+
function (t) {
14+
t.deepEqual(ss.combinations([1, 2, 3], 2), [
15+
[1, 2],
16+
[1, 3],
17+
[2, 3]
18+
]);
19+
t.end();
20+
}
21+
);
2122
t.end();
2223
});

test/k_means_cluster.test.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ function nonRNG() {
1111
}
1212

1313
test("k-means clustering test", function (t) {
14-
t.test("Single cluster of one point contains only that point", function (
15-
t
16-
) {
17-
const points = [[0.5]];
18-
const { labels, centroids } = ss.kMeansCluster(points, 1, nonRNG);
19-
t.deepEqual(labels, [0]);
20-
t.deepEqual(centroids, [[0.5]]);
21-
t.end();
22-
});
14+
t.test(
15+
"Single cluster of one point contains only that point",
16+
function (t) {
17+
const points = [[0.5]];
18+
const { labels, centroids } = ss.kMeansCluster(points, 1, nonRNG);
19+
t.deepEqual(labels, [0]);
20+
t.deepEqual(centroids, [[0.5]]);
21+
t.end();
22+
}
23+
);
2324

2425
t.test("Single cluster of two points contains both points", function (t) {
2526
const points = [[0.0], [1.0]];

test/linear_regression.test.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,37 @@ const linearRegression = require("../").linearRegression;
55
const linearRegressionLine = require("../").linearRegressionLine;
66

77
test("linear regression", function (t) {
8-
t.test("correctly generates a line for a 0, 0 to 1, 1 dataset", function (
9-
t
10-
) {
11-
const l = linearRegressionLine(
12-
linearRegression([
13-
[0, 0],
14-
[1, 1]
15-
])
16-
);
17-
t.equal(l(0), 0);
18-
t.equal(l(0.5), 0.5);
19-
t.equal(l(1), 1);
20-
t.end();
21-
});
8+
t.test(
9+
"correctly generates a line for a 0, 0 to 1, 1 dataset",
10+
function (t) {
11+
const l = linearRegressionLine(
12+
linearRegression([
13+
[0, 0],
14+
[1, 1]
15+
])
16+
);
17+
t.equal(l(0), 0);
18+
t.equal(l(0.5), 0.5);
19+
t.equal(l(1), 1);
20+
t.end();
21+
}
22+
);
2223

23-
t.test("correctly generates a line for a 0, 0 to 1, 0 dataset", function (
24-
t
25-
) {
26-
const l = linearRegressionLine(
27-
linearRegression([
28-
[0, 0],
29-
[1, 0]
30-
])
31-
);
32-
t.equal(l(0), 0);
33-
t.equal(l(0.5), 0);
34-
t.equal(l(1), 0);
35-
t.end();
36-
});
24+
t.test(
25+
"correctly generates a line for a 0, 0 to 1, 0 dataset",
26+
function (t) {
27+
const l = linearRegressionLine(
28+
linearRegression([
29+
[0, 0],
30+
[1, 0]
31+
])
32+
);
33+
t.equal(l(0), 0);
34+
t.equal(l(0.5), 0);
35+
t.equal(l(1), 0);
36+
t.end();
37+
}
38+
);
3739

3840
t.test("handles a single-point sample", function (t) {
3941
const l = linearRegressionLine(linearRegression([[0, 0]]));

test/mad.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ const test = require("tap").test;
44
const ss = require("../");
55

66
test("median absolute deviation (mad)", function (t) {
7-
t.test("median absolute deviation of an example on wikipedia", function (
8-
t
9-
) {
10-
t.equal(ss.mad([1, 1, 2, 2, 4, 6, 9]), 1);
11-
t.end();
12-
});
7+
t.test(
8+
"median absolute deviation of an example on wikipedia",
9+
function (t) {
10+
t.equal(ss.mad([1, 1, 2, 2, 4, 6, 9]), 1);
11+
t.end();
12+
}
13+
);
1314

1415
// wolfram alpha: median absolute deviation {0,1,2,3,4,5,6,7,8,9,10}
1516
t.test("median absolute deviation of 0-10", function (t) {

test/permutation_test.test.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@ test("permutation test", function (t) {
2222
t.end();
2323
}
2424
);
25-
t.test("P-value of distribution less than itself should be 1", function (
26-
t
27-
) {
28-
t.equal(
29-
ss.permutationTest(
30-
[2, 2, 2, 2, 2],
31-
[2, 2, 2, 2, 2],
32-
"greater",
33-
undefined,
34-
rng
35-
),
36-
1
37-
);
38-
t.end();
39-
});
25+
t.test(
26+
"P-value of distribution less than itself should be 1",
27+
function (t) {
28+
t.equal(
29+
ss.permutationTest(
30+
[2, 2, 2, 2, 2],
31+
[2, 2, 2, 2, 2],
32+
"greater",
33+
undefined,
34+
rng
35+
),
36+
1
37+
);
38+
t.end();
39+
}
40+
);
4041
t.test(
4142
"P-value of small sample greater than large sample should be 0",
4243
function (t) {

test/r_squared.test.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ const test = require("tap").test;
44
const ss = require("../");
55

66
test("r-squared", function (t) {
7-
t.test("says that the r squared of a two-point line is perfect", function (
8-
t
9-
) {
10-
const d = [
11-
[0, 0],
12-
[1, 1]
13-
];
14-
const l = ss.linearRegressionLine(ss.linearRegression(d));
15-
t.equal(ss.rSquared(d, l), 1);
16-
t.end();
17-
});
7+
t.test(
8+
"says that the r squared of a two-point line is perfect",
9+
function (t) {
10+
const d = [
11+
[0, 0],
12+
[1, 1]
13+
];
14+
const l = ss.linearRegressionLine(ss.linearRegression(d));
15+
t.equal(ss.rSquared(d, l), 1);
16+
t.end();
17+
}
18+
);
1819

1920
t.test(
2021
"says that the r squared of a three-point line is not perfect",

test/sample_covariance.test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ test("sample covariance", function (t) {
2121
t.end();
2222
});
2323

24-
t.test("covariance is zero for something with no correlation", function (
25-
t
26-
) {
27-
const x = [1, 2, 3, 4, 5, 6];
28-
const y = [1, 1, 2, 2, 1, 1];
29-
t.equal(rnd(ss.sampleCovariance(x, y)), 0);
30-
t.end();
31-
});
24+
t.test(
25+
"covariance is zero for something with no correlation",
26+
function (t) {
27+
const x = [1, 2, 3, 4, 5, 6];
28+
const y = [1, 1, 2, 2, 1, 1];
29+
t.equal(rnd(ss.sampleCovariance(x, y)), 0);
30+
t.end();
31+
}
32+
);
3233

3334
t.test("zero-length corner case", function (t) {
3435
t.throws(function () {

test/sample_kurtosis.test.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ test("sample kurtosis", function (t) {
2828
t.end();
2929
});
3030

31-
t.test("the kurtosis of an sample with three numbers is null", function (
32-
t
33-
) {
34-
const data = [1, 2, 3];
35-
t.throws(function () {
36-
ss.sampleKurtosis(data);
37-
});
38-
t.end();
39-
});
31+
t.test(
32+
"the kurtosis of an sample with three numbers is null",
33+
function (t) {
34+
const data = [1, 2, 3];
35+
t.throws(function () {
36+
ss.sampleKurtosis(data);
37+
});
38+
t.end();
39+
}
40+
);
4041

4142
t.test("can calculate the kurtosis of SAS example 1", function (t) {
4243
// Data and answer taken from KURTOSIS function documentation at

0 commit comments

Comments
 (0)