@@ -12,16 +12,16 @@ def test_common_tensorset(env):
12
12
13
13
tested_datatypes = ["FLOAT" , "DOUBLE" , "INT8" , "INT16" , "INT32" , "INT64" , "UINT8" , "UINT16" , "BOOL" ]
14
14
for datatype in tested_datatypes :
15
- ret = con .execute_command ('AI.TENSORSET' , 'tensor_{0 }{{0}}' .format (datatype ), datatype , 2 , 'VALUES' , 1 , 1 )
15
+ ret = con .execute_command ('AI.TENSORSET' , 'tensor_{}{{0}}' .format (datatype ), datatype , 2 , 'VALUES' , 1 , 1 )
16
16
env .assertEqual (ret , b'OK' )
17
17
18
18
ensureSlaveSynced (con , env )
19
19
20
20
# AI.TENSORGET in BLOB format and set in a new key
21
21
for datatype in tested_datatypes :
22
- _ , tensor_dtype , _ , tensor_dim , _ , tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{0 }{{0}}' .format (datatype ),
22
+ _ , tensor_dtype , _ , tensor_dim , _ , tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{}{{0}}' .format (datatype ),
23
23
'META' , 'BLOB' )
24
- ret = con .execute_command ('AI.TENSORSET' , 'tensor_blob_{0 }{{0}}' .format (datatype ), datatype , 2 , 'BLOB' , tensor_blob )
24
+ ret = con .execute_command ('AI.TENSORSET' , 'tensor_blob_{}{{0}}' .format (datatype ), datatype , 2 , 'BLOB' , tensor_blob )
25
25
env .assertEqual (ret , b'OK' )
26
26
27
27
ensureSlaveSynced (con , env )
@@ -30,8 +30,8 @@ def test_common_tensorset(env):
30
30
# Confirm that tensor_{0} and tensor_blob_{0} are equal for META VALUES BLOB
31
31
for datatype in tested_datatypes :
32
32
for reply_type in reply_types :
33
- tensor_1_reply = con .execute_command ('AI.TENSORGET' , 'tensor_{0 }{{0}}' .format (datatype ), reply_type )
34
- tensor_2_reply = con .execute_command ('AI.TENSORGET' , 'tensor_blob_{0 }{{0}}' .format (datatype ), reply_type )
33
+ tensor_1_reply = con .execute_command ('AI.TENSORGET' , 'tensor_{}{{0}}' .format (datatype ), reply_type )
34
+ tensor_2_reply = con .execute_command ('AI.TENSORGET' , 'tensor_blob_{}{{0}}' .format (datatype ), reply_type )
35
35
env .assertEqual (tensor_1_reply , tensor_2_reply )
36
36
37
37
@@ -186,15 +186,15 @@ def test_common_tensorget(env):
186
186
tested_datatypes_fp = ["FLOAT" , "DOUBLE" ]
187
187
tested_datatypes_int = ["INT8" , "INT16" , "INT32" , "INT64" , "UINT8" , "UINT16" , "BOOL" ]
188
188
for datatype in tested_datatypes :
189
- ret = con .execute_command ('AI.TENSORSET' , 'tensor_{0 }{{0}}' .format (datatype ), datatype , 2 , 'VALUES' , 1 , 1 )
189
+ ret = con .execute_command ('AI.TENSORSET' , 'tensor_{}{{0}}' .format (datatype ), datatype , 2 , 'VALUES' , 1 , 1 )
190
190
env .assertEqual (ret , b'OK' )
191
191
192
192
ensureSlaveSynced (con , env )
193
193
194
194
# AI.TENSORGET in BLOB format and set in a new key
195
195
for datatype in tested_datatypes :
196
- tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{0 }{{0}}' .format (datatype ), 'BLOB' )
197
- ret = con .execute_command ('AI.TENSORSET' , 'tensor_blob_{0 }{{0}}' .format (datatype ), datatype , 2 , 'BLOB' , tensor_blob )
196
+ tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{}{{0}}' .format (datatype ), 'BLOB' )
197
+ ret = con .execute_command ('AI.TENSORSET' , 'tensor_blob_{}{{0}}' .format (datatype ), datatype , 2 , 'BLOB' , tensor_blob )
198
198
env .assertEqual (ret , b'OK' )
199
199
200
200
ensureSlaveSynced (con , env )
@@ -203,19 +203,19 @@ def test_common_tensorget(env):
203
203
# Confirm that tensor_{0} and tensor_blog_{0} are equal for META VALUES BLOB
204
204
for datatype in tested_datatypes :
205
205
for reply_type in reply_types :
206
- tensor_1_reply = con .execute_command ('AI.TENSORGET' , 'tensor_{0 }{{0}}' .format (datatype ), reply_type )
207
- tensor_2_reply = con .execute_command ('AI.TENSORGET' , 'tensor_blob_{0 }{{0}}' .format (datatype ), reply_type )
206
+ tensor_1_reply = con .execute_command ('AI.TENSORGET' , 'tensor_{}{{0}}' .format (datatype ), reply_type )
207
+ tensor_2_reply = con .execute_command ('AI.TENSORGET' , 'tensor_blob_{}{{0}}' .format (datatype ), reply_type )
208
208
env .assertEqual (tensor_1_reply , tensor_2_reply )
209
209
210
210
# Confirm that the output is the expected for META
211
211
for datatype in tested_datatypes :
212
- _ , tensor_dtype , _ , tensor_dim = con .execute_command ('AI.TENSORGET' , 'tensor_{0 }{{0}}' .format (datatype ), "META" )
212
+ _ , tensor_dtype , _ , tensor_dim = con .execute_command ('AI.TENSORGET' , 'tensor_{}{{0}}' .format (datatype ), "META" )
213
213
env .assertEqual (datatype .encode ('utf-8' ), tensor_dtype )
214
214
env .assertEqual ([2 ], tensor_dim )
215
215
216
216
# Confirm that the output is the expected for VALUES
217
217
for datatype in tested_datatypes :
218
- _ , tensor_dtype , _ , tensor_dim , _ , tensor_values = con .execute_command ('AI.TENSORGET' , 'tensor_{0 }{{0}}' .format (datatype ),
218
+ _ , tensor_dtype , _ , tensor_dim , _ , tensor_values = con .execute_command ('AI.TENSORGET' , 'tensor_{}{{0}}' .format (datatype ),
219
219
'META' , 'VALUES' )
220
220
env .assertEqual (datatype .encode ('utf-8' ), tensor_dtype )
221
221
env .assertEqual ([2 ], tensor_dim )
@@ -226,17 +226,17 @@ def test_common_tensorget(env):
226
226
227
227
# Confirm that the output is the expected for BLOB
228
228
for datatype in tested_datatypes :
229
- _ , tensor_dtype , _ , tensor_dim , _ , tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{0 }{{0}}' .format (datatype ),
229
+ _ , tensor_dtype , _ , tensor_dim , _ , tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{}{{0}}' .format (datatype ),
230
230
'META' , 'BLOB' )
231
231
env .assertEqual (datatype .encode ('utf-8' ), tensor_dtype )
232
232
env .assertEqual ([2 ], tensor_dim )
233
233
234
234
# Confirm that default reply format is META BLOB
235
235
for datatype in tested_datatypes :
236
- _ , tensor_dtype , _ , tensor_dim , _ , tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{0 }{{0}}' .format (datatype ),
236
+ _ , tensor_dtype , _ , tensor_dim , _ , tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{}{{0}}' .format (datatype ),
237
237
'META' , 'BLOB' )
238
238
_ , tensor_dtype_default , _ , tensor_dim_default , _ , tensor_blob_default = con .execute_command ('AI.TENSORGET' ,
239
- 'tensor_{0 }{{0}}' .format (datatype ))
239
+ 'tensor_{}{{0}}' .format (datatype ))
240
240
env .assertEqual (tensor_dtype , tensor_dtype_default )
241
241
env .assertEqual (tensor_dim , tensor_dim_default )
242
242
env .assertEqual (tensor_blob , tensor_blob_default )
@@ -288,23 +288,23 @@ def test_common_tensorset_multiproc_blob(env):
288
288
tested_datatypes = ["FLOAT" , "DOUBLE" , "INT8" , "INT16" , "INT32" , "INT64" , "UINT8" , "UINT16" ]
289
289
tested_datatypes_map = {}
290
290
for datatype in tested_datatypes :
291
- ret = con .execute_command ('AI.TENSORSET' , 'tensor_{0 }{{0}}' .format (datatype ), datatype , 1 , 256 )
291
+ ret = con .execute_command ('AI.TENSORSET' , 'tensor_{}{{0}}' .format (datatype ), datatype , 1 , 256 )
292
292
env .assertEqual (ret , b'OK' )
293
293
294
294
ensureSlaveSynced (con , env )
295
295
296
296
# AI.TENSORGET in BLOB format and set in a new key
297
297
for datatype in tested_datatypes :
298
- tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{0 }{{0}}' .format (datatype ),
298
+ tensor_blob = con .execute_command ('AI.TENSORGET' , 'tensor_{}{{0}}' .format (datatype ),
299
299
'BLOB' )
300
- ret = con .execute_command ('AI.TENSORSET' , 'tensor_blob_{0 }{{0}}' .format (datatype ), datatype , 1 , 256 , 'BLOB' , tensor_blob )
300
+ ret = con .execute_command ('AI.TENSORSET' , 'tensor_blob_{}{{0}}' .format (datatype ), datatype , 1 , 256 , 'BLOB' , tensor_blob )
301
301
tested_datatypes_map [datatype ] = tensor_blob
302
302
env .assertEqual (ret , b'OK' )
303
303
304
304
def funcname (env , blob , repetitions , same_key ):
305
305
for _ in range (1 ,same_key ):
306
306
for repetion in range (1 ,repetitions ):
307
- env .execute_command ('AI.TENSORSET' , 'tensor_{0 }{{0}}' .format (repetitions ), 'FLOAT' , 1 , 256 , 'BLOB' , blob )
307
+ env .execute_command ('AI.TENSORSET' , 'tensor_{}{{0}}' .format (repetitions ), 'FLOAT' , 1 , 256 , 'BLOB' , blob )
308
308
309
309
tensor_blob = tested_datatypes_map ["FLOAT" ]
310
310
t = time .time ()
0 commit comments