From cf5e348c7dd7141415f5fecfb15251867060e2f4 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 14 Mar 2012 18:52:42 -0400 Subject: [PATCH] Raise SurfaceError if surface position data only has a single z value. If the deflection at the minimum position is over the dangerous threshold, `get_surface_position_data()` will not take any steps in. With this commit, we avoid raising a ZeroDivisionError in that situation. --- pypiezo/surface.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pypiezo/surface.py b/pypiezo/surface.py index 3257e5b..b966b7f 100644 --- a/pypiezo/surface.py +++ b/pypiezo/surface.py @@ -176,6 +176,8 @@ def analyze_surface_position_data( # Generate a reasonable guess... start_pos = int(data['z'].min()) final_pos = int(data['z'].max()) + if final_pos == start_pos: + raise SurfaceError() start_def = int(data['deflection'].min()) final_def = int(data['deflection'].max()) # start_def and start_pos are probably for 2 different points -- 2.26.2