MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / expectArraysClose

Function expectArraysClose

test_util.js:36–45  ·  view source on GitHub ↗
(actual, expected)

Source from the content-addressed store, hash-verified

34}
35
36function expectArraysClose(actual, expected) {
37 const actualValues = actual instanceof Array ? actual : actual.dataSync();
38 const expectedValues = expected instanceof Array ? expected : expected.dataSync();
39
40 expect(actualValues.length).toBe(expectedValues.length);
41 const PRECISION = 3; // corresponds to 1e-3.
42 for (let i = 0; i < actualValues.length; i++) {
43 expect(actualValues[i]).toBeCloseTo(expectedValues[i], PRECISION);
44 }
45}
46
47module.exports = {runTests, expectArraysClose};

Callers 2

snake_game_test.jsFile · 0.90
model_test.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected