Skip to content

Commit

Permalink
j trying to make the diff less gross
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Jan 16, 2025
1 parent 5fa81fe commit 531183c
Showing 1 changed file with 79 additions and 79 deletions.
158 changes: 79 additions & 79 deletions api/src/opentrons/protocol_api/instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,85 +291,6 @@ def aspirate(

return self

@requires_version(2, 0)
def mix(
self,
repetitions: int = 1,
volume: Optional[float] = None,
location: Optional[Union[types.Location, labware.Well]] = None,
rate: float = 1.0,
) -> InstrumentContext:
"""
Mix a volume of liquid by repeatedly aspirating and dispensing it in a single location.
See :ref:`mix` for examples.
:param repetitions: Number of times to mix (default is 1).
:param volume: The volume to mix, measured in µL. If unspecified, defaults
to the maximum volume for the pipette and its attached tip.
If ``mix`` is called with a volume of precisely 0, its behavior
depends on the API level of the protocol. On API levels below 2.16,
it will behave the same as a volume of ``None``/unspecified: mix
the full working volume of the pipette. On API levels at or above 2.16,
no liquid will be mixed.
:param location: The :py:class:`.Well` or :py:class:`~.types.Location` where the
pipette will mix. If unspecified, the pipette will mix at its
current position.
:param rate: How quickly the pipette aspirates and dispenses liquid while
mixing. The aspiration flow rate is calculated as ``rate``
multiplied by :py:attr:`flow_rate.aspirate <flow_rate>`. The
dispensing flow rate is calculated as ``rate`` multiplied by
:py:attr:`flow_rate.dispense <flow_rate>`. See
:ref:`new-plunger-flow-rates`.
:raises: ``UnexpectedTipRemovalError`` -- If no tip is attached to the pipette.
:returns: This instance.
.. note::
All the arguments of ``mix`` are optional. However, if you omit one of them,
all subsequent arguments must be passed as keyword arguments. For instance,
``pipette.mix(1, location=wellplate['A1'])`` is a valid call, but
``pipette.mix(1, wellplate['A1'])`` is not.
.. versionchanged:: 2.21
Does not repeatedly check for liquid presence.
"""
_log.debug(
"mixing {}uL with {} repetitions in {} at rate={}".format(
volume, repetitions, location if location else "current position", rate
)
)
if not self._core.has_tip():
raise UnexpectedTipRemovalError("mix", self.name, self.mount)

if self.api_version >= APIVersion(2, 16):
c_vol = self._core.get_available_volume() if volume is None else volume
else:
c_vol = self._core.get_available_volume() if not volume else volume

dispense_kwargs: Dict[str, Any] = {}
if self.api_version >= APIVersion(2, 16):
dispense_kwargs["push_out"] = 0.0

with publisher.publish_context(
broker=self.broker,
command=cmds.mix(
instrument=self,
repetitions=repetitions,
volume=c_vol,
location=location,
),
):
self.aspirate(volume, location, rate)
with AutoProbeDisable(self):
while repetitions - 1 > 0:
self.dispense(volume, rate=rate, **dispense_kwargs)
self.aspirate(volume, rate=rate)
repetitions -= 1
self.dispense(volume, rate=rate)
return self

@requires_version(2, 0)
def dispense(
self,
Expand Down Expand Up @@ -547,6 +468,85 @@ def dispense(

return self

@requires_version(2, 0)
def mix(
self,
repetitions: int = 1,
volume: Optional[float] = None,
location: Optional[Union[types.Location, labware.Well]] = None,
rate: float = 1.0,
) -> InstrumentContext:
"""
Mix a volume of liquid by repeatedly aspirating and dispensing it in a single location.
See :ref:`mix` for examples.
:param repetitions: Number of times to mix (default is 1).
:param volume: The volume to mix, measured in µL. If unspecified, defaults
to the maximum volume for the pipette and its attached tip.
If ``mix`` is called with a volume of precisely 0, its behavior
depends on the API level of the protocol. On API levels below 2.16,
it will behave the same as a volume of ``None``/unspecified: mix
the full working volume of the pipette. On API levels at or above 2.16,
no liquid will be mixed.
:param location: The :py:class:`.Well` or :py:class:`~.types.Location` where the
pipette will mix. If unspecified, the pipette will mix at its
current position.
:param rate: How quickly the pipette aspirates and dispenses liquid while
mixing. The aspiration flow rate is calculated as ``rate``
multiplied by :py:attr:`flow_rate.aspirate <flow_rate>`. The
dispensing flow rate is calculated as ``rate`` multiplied by
:py:attr:`flow_rate.dispense <flow_rate>`. See
:ref:`new-plunger-flow-rates`.
:raises: ``UnexpectedTipRemovalError`` -- If no tip is attached to the pipette.
:returns: This instance.
.. note::
All the arguments of ``mix`` are optional. However, if you omit one of them,
all subsequent arguments must be passed as keyword arguments. For instance,
``pipette.mix(1, location=wellplate['A1'])`` is a valid call, but
``pipette.mix(1, wellplate['A1'])`` is not.
.. versionchanged:: 2.21
Does not repeatedly check for liquid presence.
"""
_log.debug(
"mixing {}uL with {} repetitions in {} at rate={}".format(
volume, repetitions, location if location else "current position", rate
)
)
if not self._core.has_tip():
raise UnexpectedTipRemovalError("mix", self.name, self.mount)

if self.api_version >= APIVersion(2, 16):
c_vol = self._core.get_available_volume() if volume is None else volume
else:
c_vol = self._core.get_available_volume() if not volume else volume

dispense_kwargs: Dict[str, Any] = {}
if self.api_version >= APIVersion(2, 16):
dispense_kwargs["push_out"] = 0.0

with publisher.publish_context(
broker=self.broker,
command=cmds.mix(
instrument=self,
repetitions=repetitions,
volume=c_vol,
location=location,
),
):
self.aspirate(volume, location, rate)
with AutoProbeDisable(self):
while repetitions - 1 > 0:
self.dispense(volume, rate=rate, **dispense_kwargs)
self.aspirate(volume, rate=rate)
repetitions -= 1
self.dispense(volume, rate=rate)
return self

@requires_version(2, 0)
def blow_out(
self,
Expand Down

0 comments on commit 531183c

Please sign in to comment.