Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions tfjs-core/scripts/test-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
33 changes: 18 additions & 15 deletions tfjs-core/src/ops/array_ops_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,25 +1176,28 @@ 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];

// 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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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);
});
});

Expand Down