@@ -29,24 +29,25 @@ def bench_array_to_file():
2929 sys .stdout .flush ()
3030 print_git_title ('\n Array to file' )
3131 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 ))
3334 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 ))
3536 # Set a lot of NaNs to check timing
3637 arr [:, :, :, 1 ] = np .nan
3738 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 ))
3940 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 ))
4142 # Set a lot of infs to check timing
4243 arr [:, :, :, 1 ] = np .inf
4344 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 ))
4546 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 ))
4748 # Int16 input, float output
4849 arr = np .random .random_integers (low = - 1000 , high = 1000 , size = img_shape )
4950 arr = arr .astype (np .int16 )
5051 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 ))
5253 sys .stdout .flush ()
0 commit comments