Raise SurfaceError if surface position data only has a single z value.
authorW. Trevor King <wking@drexel.edu>
Wed, 14 Mar 2012 22:52:42 +0000 (18:52 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 14 Mar 2012 22:52:42 +0000 (18:52 -0400)
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

index 3257e5b75fb3cc02d2941110ced8e96cd566b1cb..b966b7f9a765b64e43b5a9d88c99c40f7ff36baf 100644 (file)
@@ -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