From a49433210c125f450e054d2bd45f4888d5cec760 Mon Sep 17 00:00:00 2001 From: Daniel Smilkov Date: Thu, 15 Aug 2019 11:41:54 -0400 Subject: [PATCH 1/2] save --- tfjs-core/scripts/test-integration.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tfjs-core/scripts/test-integration.js b/tfjs-core/scripts/test-integration.js index f86b2243137..d11e8e7abfe 100755 --- a/tfjs-core/scripts/test-integration.js +++ b/tfjs-core/scripts/test-integration.js @@ -17,17 +17,22 @@ const {exec} = require('../../scripts/test-util'); const fs = require('fs'); -let shouldRunIntegration = false; -if (process.env.NIGHTLY === 'true') { - shouldRunIntegration = true; -} else { + +function shouldRunIntegration() { + if (process.env.NIGHTLY === 'true') { + return true; + } const diffFile = 'diff'; + if (!fs.existsSync(diffFile)) { + return false; + } let diffContents = `${fs.readFileSync(diffFile)}`; - - if (diffContents.indexOf('src/version.ts') !== -1) { - shouldRunIntegration = true; + if (diffContents.indexOf('src/version.ts') === -1) { + return false; } + return true; } -if (shouldRunIntegration) { + +if (shouldRunIntegration()) { exec('./scripts/test-integration.sh'); } From 82430b81e0e69c9f21a90fd40d64875df3d3adf2 Mon Sep 17 00:00:00 2001 From: Daniel Smilkov Date: Thu, 15 Aug 2019 12:41:25 -0400 Subject: [PATCH 2/2] save --- tfjs-core/src/ops/array_ops_test.ts | 33 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/tfjs-core/src/ops/array_ops_test.ts b/tfjs-core/src/ops/array_ops_test.ts index 809fca99c47..4d4d357f27b 100644 --- a/tfjs-core/src/ops/array_ops_test.ts +++ b/tfjs-core/src/ops/array_ops_test.ts @@ -1176,6 +1176,9 @@ describeWithFlags('truncatedNormal', ALL_ENVS, () => { }); }); +const GAMMA_MIN = 0; +const GAMMA_MAX = 40; + describeWithFlags('randomGamma', ALL_ENVS, () => { it('should return a random 1D float32 array', async () => { const shape: [number] = [10]; @@ -1183,18 +1186,18 @@ describeWithFlags('randomGamma', ALL_ENVS, () => { // Ensure defaults to float32 w/o type: let result = tf.randomGamma(shape, 2, 2); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); result = tf.randomGamma(shape, 2, 2, 'float32'); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); it('should return a random 1D int32 array', async () => { const shape: [number] = [10]; const result = tf.randomGamma(shape, 2, 2, 'int32'); expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); it('should return a random 2D float32 array', async () => { @@ -1203,18 +1206,18 @@ describeWithFlags('randomGamma', ALL_ENVS, () => { // Ensure defaults to float32 w/o type: let result = tf.randomGamma(shape, 2, 2); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); result = tf.randomGamma(shape, 2, 2, 'float32'); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); it('should return a random 2D int32 array', async () => { const shape: [number, number] = [3, 4]; const result = tf.randomGamma(shape, 2, 2, 'int32'); expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); it('should return a random 3D float32 array', async () => { @@ -1223,18 +1226,18 @@ describeWithFlags('randomGamma', ALL_ENVS, () => { // Ensure defaults to float32 w/o type: let result = tf.randomGamma(shape, 2, 2); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); result = tf.randomGamma(shape, 2, 2, 'float32'); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); it('should return a random 3D int32 array', async () => { const shape: [number, number, number] = [3, 4, 5]; const result = tf.randomGamma(shape, 2, 2, 'int32'); expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); it('should return a random 4D float32 array', async () => { @@ -1243,18 +1246,18 @@ describeWithFlags('randomGamma', ALL_ENVS, () => { // Ensure defaults to float32 w/o type: let result = tf.randomGamma(shape, 2, 2); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); result = tf.randomGamma(shape, 2, 2, 'float32'); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); it('should return a random 4D int32 array', async () => { const shape: [number, number, number, number] = [3, 4, 5, 6]; const result = tf.randomGamma(shape, 2, 2, 'int32'); expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); it('should return a random 5D float32 array', async () => { @@ -1263,18 +1266,18 @@ describeWithFlags('randomGamma', ALL_ENVS, () => { // Ensure defaults to float32 w/o type: let result = tf.randomGamma(shape, 2, 2); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); result = tf.randomGamma(shape, 2, 2, 'float32'); expect(result.dtype).toBe('float32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); it('should return a random 5D int32 array', async () => { const shape: [number, number, number, number, number] = [2, 3, 4, 5, 6]; const result = tf.randomGamma(shape, 2, 2, 'int32'); expect(result.dtype).toBe('int32'); - expectValuesInRange(await result.data(), 0, 30); + expectValuesInRange(await result.data(), GAMMA_MIN, GAMMA_MAX); }); });