Skip to content

Commit da5e3da

Browse files
authored
adds optional height argument to touch_tip() (#155)
* adds optional height argument to touch_tip() * pylama
1 parent a738c1d commit da5e3da

File tree

2 files changed

+64
-5
lines changed

2 files changed

+64
-5
lines changed

opentrons/instruments/pipette.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,13 @@ def touch_tip(self, location=None, enqueue=True):
691691
>>> p200.dispense(plate[1]).touch_tip() # doctest: +ELLIPSIS
692692
<opentrons.instruments.pipette.Pipette object at ...>
693693
"""
694+
height_offset = 0
695+
694696
def _setup():
695-
nonlocal location
697+
nonlocal location, height_offset
698+
if isinstance(location, (int, float, complex)):
699+
height_offset = location
700+
location = self.previous_placeable
696701
self._associate_placeable(location)
697702

698703
def _do():
@@ -705,20 +710,34 @@ def _do():
705710
else:
706711
location = self.previous_placeable
707712

713+
v_offset = (0, 0, height_offset)
714+
708715
self.move_to(
709-
(location, location.from_center(x=1, y=0, z=1)),
716+
(
717+
location,
718+
location.from_center(x=1, y=0, z=1) + v_offset
719+
),
710720
strategy='direct',
711721
enqueue=False)
712722
self.move_to(
713-
(location, location.from_center(x=-1, y=0, z=1)),
723+
(
724+
location,
725+
location.from_center(x=-1, y=0, z=1) + v_offset
726+
),
714727
strategy='direct',
715728
enqueue=False)
716729
self.move_to(
717-
(location, location.from_center(x=0, y=1, z=1)),
730+
(
731+
location,
732+
location.from_center(x=0, y=1, z=1) + v_offset
733+
),
718734
strategy='direct',
719735
enqueue=False)
720736
self.move_to(
721-
(location, location.from_center(x=0, y=-1, z=1)),
737+
(
738+
location,
739+
location.from_center(x=0, y=-1, z=1) + v_offset
740+
),
722741
strategy='direct',
723742
enqueue=False)
724743

tests/opentrons/labware/test_pipette.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,46 @@ def test_distribute(self):
461461
]
462462
)
463463

464+
def test_touch_tip(self):
465+
self.p200.move_to = mock.Mock()
466+
self.p200.touch_tip(self.plate[0])
467+
self.p200.touch_tip(-3)
468+
469+
self.robot.simulate()
470+
471+
from pprint import pprint
472+
pprint(self.p200.move_to.mock_calls)
473+
474+
expected = [
475+
mock.call(self.plate[0], enqueue=False, strategy='arc'),
476+
mock.call(
477+
(self.plate[0], (6.40, 3.20, 10.50)),
478+
enqueue=False, strategy='direct'),
479+
mock.call(
480+
(self.plate[0], (0.00, 3.20, 10.50)),
481+
enqueue=False, strategy='direct'),
482+
mock.call(
483+
(self.plate[0], (3.20, 6.40, 10.50)),
484+
enqueue=False, strategy='direct'),
485+
mock.call(
486+
(self.plate[0], (3.20, 0.00, 10.50)),
487+
enqueue=False, strategy='direct'),
488+
mock.call(self.plate[0], enqueue=False, strategy='arc'),
489+
mock.call(
490+
(self.plate[0], (6.40, 3.20, 7.50)),
491+
enqueue=False, strategy='direct'),
492+
mock.call(
493+
(self.plate[0], (0.00, 3.20, 7.50)),
494+
enqueue=False, strategy='direct'),
495+
mock.call(
496+
(self.plate[0], (3.20, 6.40, 7.50)),
497+
enqueue=False, strategy='direct'),
498+
mock.call(
499+
(self.plate[0], (3.20, 0.00, 7.50)),
500+
enqueue=False, strategy='direct')]
501+
502+
self.assertEquals(expected, self.p200.move_to.mock_calls)
503+
464504
def test_mix(self):
465505
# It is necessary to aspirate before it is mocked out
466506
# so that you have liquid

0 commit comments

Comments
 (0)