From a93601346b535c48c18d03e0d67c3d8f7243f313 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Fri, 20 Jan 2017 16:23:50 +0000 Subject: timing: "normalize" negative times too Use the same scale. Signed-off-by: Karl Palsson --- decoders/timing/pd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'decoders') diff --git a/decoders/timing/pd.py b/decoders/timing/pd.py index b694c1d..c88b8b5 100644 --- a/decoders/timing/pd.py +++ b/decoders/timing/pd.py @@ -25,19 +25,19 @@ class SamplerateError(Exception): pass def normalize_time(t): - if t >= 1.0: + if abs(t) >= 1.0: return '%.3f s (%.3f Hz)' % (t, (1/t)) - elif t >= 0.001: + elif abs(t) >= 0.001: if 1/t/1000 < 1: return '%.3f ms (%.3f Hz)' % (t * 1000.0, (1/t)) else: return '%.3f ms (%.3f kHz)' % (t * 1000.0, (1/t)/1000) - elif t >= 0.000001: + elif abs(t) >= 0.000001: if 1/t/1000/1000 < 1: return '%.3f μs (%.3f kHz)' % (t * 1000.0 * 1000.0, (1/t)/1000) else: return '%.3f μs (%.3f MHz)' % (t * 1000.0 * 1000.0, (1/t)/1000/1000) - elif t >= 0.000000001: + elif abs(t) >= 0.000000001: if 1/t/1000/1000/1000: return '%.3f ns (%.3f MHz)' % (t * 1000.0 * 1000.0 * 1000.0, (1/t)/1000/1000) else: -- cgit v1.2.3-70-g09d2