From 531183cf852ec9221af7b8203fc9913d3718116b Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Thu, 16 Jan 2025 16:32:37 -0500 Subject: [PATCH] j trying to make the diff less gross --- .../protocol_api/instrument_context.py | 158 +++++++++--------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/api/src/opentrons/protocol_api/instrument_context.py b/api/src/opentrons/protocol_api/instrument_context.py index ea2eb334cff..43abafe885c 100644 --- a/api/src/opentrons/protocol_api/instrument_context.py +++ b/api/src/opentrons/protocol_api/instrument_context.py @@ -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 `. The - dispensing flow rate is calculated as ``rate`` multiplied by - :py:attr:`flow_rate.dispense `. 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, @@ -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 `. The + dispensing flow rate is calculated as ``rate`` multiplied by + :py:attr:`flow_rate.dispense `. 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,