shithub: aubio

Download patch

ref: fbd7c80e36a2b490316585eeb07e5e467056903d
parent: 0229e51755a167111e1345908022337b0115e145
author: Paul Brossier <piem@piem.org>
date: Mon Apr 18 20:49:21 EDT 2016

python/tests/test_source.py: simplify print

--- a/python/tests/test_source.py
+++ b/python/tests/test_source.py
@@ -38,10 +38,9 @@
             vec, read = f()
             total_frames += read
             if read < f.hop_size: break
-        print ("read", "%.2fs" % (total_frames / float(f.samplerate) ) ),
-        print ("(", total_frames, "frames", "in" ),
-        print (total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")" ),
-        print ("from", f.uri)
+        result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}"
+        params = total_frames / float(f.samplerate), total_frames, int(total_frames/f.hop_size), f.samplerate, f.uri
+        print (result_str.format(*params))
         return total_frames
 
     def test_samplerate_hopsize(self):
@@ -108,11 +107,9 @@
             vec, read = f.do_multi()
             total_frames += read
             if read < f.hop_size: break
-        print ("read", "%.2fs" % (total_frames / float(f.samplerate) ) ),
-        print ("(", total_frames, "frames", "in" ),
-        print (f.channels, "channels and" ),
-        print (total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")" ),
-        print ("from", f.uri)
+        result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}"
+        params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri
+        print (result_str.format(*params))
         return total_frames
 
 if __name__ == '__main__':