From d5e846c4a54a78204784739e155a5317f4ecfcf1 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 6 Mar 2013 16:56:04 -0500 Subject: [PATCH] demos/demo_beats_and_tempo.py: skip plot if not beats --- python/demos/demo_beats_and_tempo.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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' -- 2.26.2