From: Paul Brossier Date: Wed, 6 Mar 2013 21:56:04 +0000 (-0500) Subject: demos/demo_beats_and_tempo.py: skip plot if not beats X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d5e846c4a54a78204784739e155a5317f4ecfcf1;p=aubio.git demos/demo_beats_and_tempo.py: skip plot if not beats --- diff --git a/python/demos/demo_beats_and_tempo.py b/python/demos/demo_beats_and_tempo.py index 2b33bb19..76094e1f 100755 --- a/python/demos/demo_beats_and_tempo.py +++ b/python/demos/demo_beats_and_tempo.py @@ -31,9 +31,11 @@ while True: periods = [60./(b - a) for a,b in zip(beats[:-1],beats[1:])] from numpy import mean, median -print 'mean period:', mean(periods), 'bpm' -print 'median period:', median(periods), 'bpm' - -from pylab import plot, show -plot(beats[1:], periods) -show() +if len(periods): + print 'mean period:', "%.2f" % mean(periods), 'bpm', 'median', "%.2f" % median(periods), 'bpm' + if 0: + from pylab import plot, show + plot(beats[1:], periods) + show() +else: + print 'mean period:', "%.2f" % 0, 'bpm', 'median', "%.2f" % 0, 'bpm'