@@ -29,24 +29,25 @@ def bench_array_to_file():
29
29
sys .stdout .flush ()
30
30
print_git_title ('\n Array to file' )
31
31
mtime = measure ('array_to_file(arr, BytesIO(), np.float32)' , repeat )
32
- print ('%30s %6.2f' % ('Save float64 to float32' , mtime ))
32
+ fmt = '{:30s} {:6.2f}' .format
33
+ print (fmt ('Save float64 to float32' , mtime ))
33
34
mtime = measure ('array_to_file(arr, BytesIO(), np.int16)' , repeat )
34
- print ('%30s %6.2f' % ('Save float64 to int16' , mtime ))
35
+ print (fmt ('Save float64 to int16' , mtime ))
35
36
# Set a lot of NaNs to check timing
36
37
arr [:, :, :, 1 ] = np .nan
37
38
mtime = measure ('array_to_file(arr, BytesIO(), np.float32)' , repeat )
38
- print ('%30s %6.2f' % ('Save float64 to float32, NaNs' , mtime ))
39
+ print (fmt ('Save float64 to float32, NaNs' , mtime ))
39
40
mtime = measure ('array_to_file(arr, BytesIO(), np.int16)' , repeat )
40
- print ('%30s %6.2f' % ('Save float64 to int16, NaNs' , mtime ))
41
+ print (fmt ('Save float64 to int16, NaNs' , mtime ))
41
42
# Set a lot of infs to check timing
42
43
arr [:, :, :, 1 ] = np .inf
43
44
mtime = measure ('array_to_file(arr, BytesIO(), np.float32)' , repeat )
44
- print ('%30s %6.2f' % ('Save float64 to float32, infs' , mtime ))
45
+ print (fmt ('Save float64 to float32, infs' , mtime ))
45
46
mtime = measure ('array_to_file(arr, BytesIO(), np.int16)' , repeat )
46
- print ('%30s %6.2f' % ('Save float64 to int16, infs' , mtime ))
47
+ print (fmt ('Save float64 to int16, infs' , mtime ))
47
48
# Int16 input, float output
48
49
arr = np .random .random_integers (low = - 1000 , high = 1000 , size = img_shape )
49
50
arr = arr .astype (np .int16 )
50
51
mtime = measure ('array_to_file(arr, BytesIO(), np.float32)' , repeat )
51
- print ('%30s %6.2f' % ('Save Int16 to float32' , mtime ))
52
+ print (fmt ('Save Int16 to float32' , mtime ))
52
53
sys .stdout .flush ()
0 commit comments