From: W. Trevor King Date: Wed, 14 Mar 2012 22:52:42 +0000 (-0400) Subject: Raise SurfaceError if surface position data only has a single z value. X-Git-Tag: 0.6~16 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cf5e348c7dd7141415f5fecfb15251867060e2f4;p=pypiezo.git 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. --- 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