@@ -1176,11 +1176,113 @@ describeWithFlags('truncatedNormal', ALL_ENVS, () => {
1176
1176
} ) ;
1177
1177
} ) ;
1178
1178
1179
+ describeWithFlags ( 'randomGamma' , ALL_ENVS , ( ) => {
1180
+ it ( 'should return a random 1D float32 array' , async ( ) => {
1181
+ const shape : [ number ] = [ 10 ] ;
1182
+
1183
+ // Ensure defaults to float32 w/o type:
1184
+ let result = tf . randomGamma ( shape , 2 , 2 ) ;
1185
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1186
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1187
+
1188
+ result = tf . randomGamma ( shape , 2 , 2 , 'float32' ) ;
1189
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1190
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1191
+ } ) ;
1192
+
1193
+ it ( 'should return a random 1D int32 array' , async ( ) => {
1194
+ const shape : [ number ] = [ 10 ] ;
1195
+ const result = tf . randomGamma ( shape , 2 , 2 , 'int32' ) ;
1196
+ expect ( result . dtype ) . toBe ( 'int32' ) ;
1197
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1198
+ } ) ;
1199
+
1200
+ it ( 'should return a random 2D float32 array' , async ( ) => {
1201
+ const shape : [ number , number ] = [ 3 , 4 ] ;
1202
+
1203
+ // Ensure defaults to float32 w/o type:
1204
+ let result = tf . randomGamma ( shape , 2 , 2 ) ;
1205
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1206
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1207
+
1208
+ result = tf . randomGamma ( shape , 2 , 2 , 'float32' ) ;
1209
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1210
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1211
+ } ) ;
1212
+
1213
+ it ( 'should return a random 2D int32 array' , async ( ) => {
1214
+ const shape : [ number , number ] = [ 3 , 4 ] ;
1215
+ const result = tf . randomGamma ( shape , 2 , 2 , 'int32' ) ;
1216
+ expect ( result . dtype ) . toBe ( 'int32' ) ;
1217
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1218
+ } ) ;
1219
+
1220
+ it ( 'should return a random 3D float32 array' , async ( ) => {
1221
+ const shape : [ number , number , number ] = [ 3 , 4 , 5 ] ;
1222
+
1223
+ // Ensure defaults to float32 w/o type:
1224
+ let result = tf . randomGamma ( shape , 2 , 2 ) ;
1225
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1226
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1227
+
1228
+ result = tf . randomGamma ( shape , 2 , 2 , 'float32' ) ;
1229
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1230
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1231
+ } ) ;
1232
+
1233
+ it ( 'should return a random 3D int32 array' , async ( ) => {
1234
+ const shape : [ number , number , number ] = [ 3 , 4 , 5 ] ;
1235
+ const result = tf . randomGamma ( shape , 2 , 2 , 'int32' ) ;
1236
+ expect ( result . dtype ) . toBe ( 'int32' ) ;
1237
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1238
+ } ) ;
1239
+
1240
+ it ( 'should return a random 4D float32 array' , async ( ) => {
1241
+ const shape : [ number , number , number , number ] = [ 3 , 4 , 5 , 6 ] ;
1242
+
1243
+ // Ensure defaults to float32 w/o type:
1244
+ let result = tf . randomGamma ( shape , 2 , 2 ) ;
1245
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1246
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1247
+
1248
+ result = tf . randomGamma ( shape , 2 , 2 , 'float32' ) ;
1249
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1250
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1251
+ } ) ;
1252
+
1253
+ it ( 'should return a random 4D int32 array' , async ( ) => {
1254
+ const shape : [ number , number , number , number ] = [ 3 , 4 , 5 , 6 ] ;
1255
+ const result = tf . randomGamma ( shape , 2 , 2 , 'int32' ) ;
1256
+ expect ( result . dtype ) . toBe ( 'int32' ) ;
1257
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1258
+ } ) ;
1259
+
1260
+ it ( 'should return a random 5D float32 array' , async ( ) => {
1261
+ const shape : [ number , number , number , number , number ] = [ 2 , 3 , 4 , 5 , 6 ] ;
1262
+
1263
+ // Ensure defaults to float32 w/o type:
1264
+ let result = tf . randomGamma ( shape , 2 , 2 ) ;
1265
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1266
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1267
+
1268
+ result = tf . randomGamma ( shape , 2 , 2 , 'float32' ) ;
1269
+ expect ( result . dtype ) . toBe ( 'float32' ) ;
1270
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1271
+ } ) ;
1272
+
1273
+ it ( 'should return a random 5D int32 array' , async ( ) => {
1274
+ const shape : [ number , number , number , number , number ] = [ 2 , 3 , 4 , 5 , 6 ] ;
1275
+ const result = tf . randomGamma ( shape , 2 , 2 , 'int32' ) ;
1276
+ expect ( result . dtype ) . toBe ( 'int32' ) ;
1277
+ expectValuesInRange ( await result . data ( ) , 0 , 30 ) ;
1278
+ } ) ;
1279
+ } ) ;
1280
+
1179
1281
describeWithFlags ( 'randomUniform' , ALL_ENVS , ( ) => {
1180
1282
it ( 'should return a random 1D float32 array' , async ( ) => {
1181
1283
const shape : [ number ] = [ 10 ] ;
1182
1284
1183
- // Enusre defaults to float32 w/o type:
1285
+ // Ensure defaults to float32 w/o type:
1184
1286
let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
1185
1287
expect ( result . dtype ) . toBe ( 'float32' ) ;
1186
1288
expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
@@ -1207,7 +1309,7 @@ describeWithFlags('randomUniform', ALL_ENVS, () => {
1207
1309
it ( 'should return a random 2D float32 array' , async ( ) => {
1208
1310
const shape : [ number , number ] = [ 3 , 4 ] ;
1209
1311
1210
- // Enusre defaults to float32 w/o type:
1312
+ // Ensure defaults to float32 w/o type:
1211
1313
let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
1212
1314
expect ( result . dtype ) . toBe ( 'float32' ) ;
1213
1315
expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
@@ -1234,7 +1336,7 @@ describeWithFlags('randomUniform', ALL_ENVS, () => {
1234
1336
it ( 'should return a random 3D float32 array' , async ( ) => {
1235
1337
const shape : [ number , number , number ] = [ 3 , 4 , 5 ] ;
1236
1338
1237
- // Enusre defaults to float32 w/o type:
1339
+ // Ensure defaults to float32 w/o type:
1238
1340
let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
1239
1341
expect ( result . dtype ) . toBe ( 'float32' ) ;
1240
1342
expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
@@ -1261,7 +1363,7 @@ describeWithFlags('randomUniform', ALL_ENVS, () => {
1261
1363
it ( 'should return a random 4D float32 array' , async ( ) => {
1262
1364
const shape : [ number , number , number , number ] = [ 3 , 4 , 5 , 6 ] ;
1263
1365
1264
- // Enusre defaults to float32 w/o type:
1366
+ // Ensure defaults to float32 w/o type:
1265
1367
let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
1266
1368
expect ( result . dtype ) . toBe ( 'float32' ) ;
1267
1369
expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
@@ -1288,7 +1390,7 @@ describeWithFlags('randomUniform', ALL_ENVS, () => {
1288
1390
it ( 'should return a random 5D float32 array' , async ( ) => {
1289
1391
const shape : [ number , number , number , number , number ] = [ 2 , 3 , 4 , 5 , 6 ] ;
1290
1392
1291
- // Enusre defaults to float32 w/o type:
1393
+ // Ensure defaults to float32 w/o type:
1292
1394
let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
1293
1395
expect ( result . dtype ) . toBe ( 'float32' ) ;
1294
1396
expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
0 commit comments