@@ -1176,11 +1176,113 @@ describeWithFlags('truncatedNormal', ALL_ENVS, () => {
11761176 } ) ;
11771177} ) ;
11781178
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+
11791281describeWithFlags ( 'randomUniform' , ALL_ENVS , ( ) => {
11801282 it ( 'should return a random 1D float32 array' , async ( ) => {
11811283 const shape : [ number ] = [ 10 ] ;
11821284
1183- // Enusre defaults to float32 w/o type:
1285+ // Ensure defaults to float32 w/o type:
11841286 let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
11851287 expect ( result . dtype ) . toBe ( 'float32' ) ;
11861288 expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
@@ -1207,7 +1309,7 @@ describeWithFlags('randomUniform', ALL_ENVS, () => {
12071309 it ( 'should return a random 2D float32 array' , async ( ) => {
12081310 const shape : [ number , number ] = [ 3 , 4 ] ;
12091311
1210- // Enusre defaults to float32 w/o type:
1312+ // Ensure defaults to float32 w/o type:
12111313 let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
12121314 expect ( result . dtype ) . toBe ( 'float32' ) ;
12131315 expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
@@ -1234,7 +1336,7 @@ describeWithFlags('randomUniform', ALL_ENVS, () => {
12341336 it ( 'should return a random 3D float32 array' , async ( ) => {
12351337 const shape : [ number , number , number ] = [ 3 , 4 , 5 ] ;
12361338
1237- // Enusre defaults to float32 w/o type:
1339+ // Ensure defaults to float32 w/o type:
12381340 let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
12391341 expect ( result . dtype ) . toBe ( 'float32' ) ;
12401342 expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
@@ -1261,7 +1363,7 @@ describeWithFlags('randomUniform', ALL_ENVS, () => {
12611363 it ( 'should return a random 4D float32 array' , async ( ) => {
12621364 const shape : [ number , number , number , number ] = [ 3 , 4 , 5 , 6 ] ;
12631365
1264- // Enusre defaults to float32 w/o type:
1366+ // Ensure defaults to float32 w/o type:
12651367 let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
12661368 expect ( result . dtype ) . toBe ( 'float32' ) ;
12671369 expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
@@ -1288,7 +1390,7 @@ describeWithFlags('randomUniform', ALL_ENVS, () => {
12881390 it ( 'should return a random 5D float32 array' , async ( ) => {
12891391 const shape : [ number , number , number , number , number ] = [ 2 , 3 , 4 , 5 , 6 ] ;
12901392
1291- // Enusre defaults to float32 w/o type:
1393+ // Ensure defaults to float32 w/o type:
12921394 let result = tf . randomUniform ( shape , 0 , 2.5 ) ;
12931395 expect ( result . dtype ) . toBe ( 'float32' ) ;
12941396 expectValuesInRange ( await result . data ( ) , 0 , 2.5 ) ;
0 commit comments