From: W. Trevor King Date: Fri, 16 Mar 2012 04:18:38 +0000 (-0400) Subject: Fix soft-jump bailout logic when we don't know the current position. X-Git-Tag: 0.7~18 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=80ff3bc8362b6c50c3eac6e365e69c10655a8afa;p=pypiezo.git Fix soft-jump bailout logic when we don't know the current position. --- diff --git a/pypiezo/base.py b/pypiezo/base.py index 2e59e60..3be164f 100644 --- a/pypiezo/base.py +++ b/pypiezo/base.py @@ -741,7 +741,8 @@ class Piezo (object): def jump(self, axis_name, position, steps=1, sleep=None): "Move the output named `axis_name` to `position`." - _LOG.debug('jump %s to %s in %d steps' % (axis_name, position, steps)) + _LOG.debug('jump {} to {} in {} steps'.format( + axis_name, position, steps)) if steps > 1: try: orig_pos = self.last_output[axis_name] @@ -750,9 +751,12 @@ class Piezo (object): ("cannot make a soft jump to {} because we don't have a " 'last-output position for {}').format( position, axis_name)) - steps = 1 + return self.jump(axis_name=axis_name, position=position) else: - for pos in _numpy.linspace(orig_pos, position, steps+1)[1:]: + for i,pos in enumerate(_numpy.linspace( + orig_pos, position, steps+1))[1:]: + _LOG.debug('jump {} to {} ({} of {} steps)'.format( + axis_name, pos, i, steps)) self.jump(axis_name=axis_name, position=pos) if sleep: _sleep(sleep)