Skip to content

Commit ba0e50d

Browse files
chore: Unit tests
1 parent 84207e5 commit ba0e50d

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

lib/agents/determinist-pg.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("DeterministPG", () => {
4040
outputSize: 7,
4141
activation: "sigmoid",
4242
});
43-
expect(new DeterministPG(agent.toJSON())).toMatchObject(agent);
43+
expect(new DeterministPG(agent.toJSON()).toJSON()).toMatchObject(agent.toJSON());
4444
});
4545
});
4646
});

lib/agents/dqn-agent.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("DQNAgent", () => {
4949
outputSize: 10,
5050
activation: "sigmoid",
5151
});
52-
expect(new DQNAgent(agent.toJSON())).toMatchObject(agent);
52+
expect(new DQNAgent(agent.toJSON()).toJSON()).toMatchObject(agent.toJSON());
5353
});
5454
});
5555
});

lib/lstm.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe("LSTM", () => {
3333
Wch: new Mat(2, 2),
3434
bc: new Mat(2, 1),
3535
}],
36-
Whd: new Mat(3, 0),
36+
Whd: new Mat(3, 2),
3737
bd: new Mat(3, 1),
3838
});
3939
});

lib/net.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ describe("Net", () => {
7979
W2: net.weights[1].toJSON(),
8080
b2: net.biases[1].toJSON(),
8181
};
82-
expect(Net.fromJSON(json)).toEqual(net);
82+
expect(Net.fromJSON(json).toJSON()).toEqual(net.toJSON());
8383
});
8484
});
8585
describe("when using standard json", () => {
8686
it("calls fromJSON() provides equivalent net", () => {
8787
const net = new Net(1, [2] ,3);
8888
const json = net.toJSON();
89-
expect(Net.fromJSON(json)).toEqual(net);
89+
expect(Net.fromJSON(json).toJSON()).toEqual(net.toJSON());
9090
});
9191
});
9292
describe("when using unknown json", () => {

lib/rand-mat.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ describe("RandMat", () => {
66
const mat = new RandMat(2, 2, 2, 0.08);
77
expect(mat.n).toEqual(2);
88
expect(mat.d).toEqual(2);
9-
expect(mat.mu).toEqual(2);
10-
expect(mat.std).toEqual(0.08);
119
expect(mat.w).not.toEqual(new Float64Array([0,0,0,0]));
1210
});
1311
});

lib/rand-mat.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ export class RandMat extends Mat {
55
constructor(
66
n: number,
77
d: number,
8-
public mu: number,
9-
public std: number
8+
private mu: number,
9+
private std: number
1010
) {
1111
super(n, d);
1212
this.fillRandn(mu, std);
1313
//fillRand(this,-std,std); // kind of :P
1414
}
15-
16-
//TODO: mu and std from JSON?
1715
}

0 commit comments

Comments
 (0)