Skip to content

Commit

Permalink
constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
amit lissack committed Apr 5, 2022
1 parent e33ea74 commit e3fdba8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
10 changes: 6 additions & 4 deletions api/src/opentrons/hardware_control/instrument_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@

AxisType = TypeVar("AxisType", Axis, OT3Axis)

PLUNGER_CACHE_LIMIT = 32


@dataclass(frozen=True)
class LiquidActionSpec(Generic[AxisType]):
Expand Down Expand Up @@ -394,22 +396,22 @@ def ready_for_tip_action(self, target: Pipette, action: HardwareAction) -> None:
raise RuntimeError("Pipette not ready to aspirate")
self._ihp_log.debug(f"{action} on {target.name}")

@functools.lru_cache(10)
@functools.lru_cache(PLUNGER_CACHE_LIMIT)
def plunger_position(
self, instr: Pipette, ul: float, action: "UlPerMmAction"
) -> float:
mm = ul / instr.ul_per_mm(ul, action)
position = mm + instr.config.bottom
return round(position, 6)

@functools.lru_cache(10)
@functools.lru_cache(PLUNGER_CACHE_LIMIT)
def plunger_speed(
self, instr: Pipette, ul_per_s: float, action: "UlPerMmAction"
) -> float:
mm_per_s = ul_per_s / instr.ul_per_mm(instr.config.max_volume, action)
return round(mm_per_s, 6)

@functools.lru_cache(10)
@functools.lru_cache(PLUNGER_CACHE_LIMIT)
def plunger_flowrate(
self, instr: Pipette, mm_per_s: float, action: "UlPerMmAction"
) -> float:
Expand Down Expand Up @@ -900,7 +902,7 @@ def get_pipette(self, mount: MountType) -> Pipette:
class OT3InstrumentHandler(InstrumentHandlerProvider[OT3Mount]):
"""Override for correct plunger_position."""

@functools.lru_cache(10)
@functools.lru_cache(PLUNGER_CACHE_LIMIT)
def plunger_position(
self, instr: Pipette, ul: float, action: "UlPerMmAction"
) -> float:
Expand Down
3 changes: 1 addition & 2 deletions api/src/opentrons/protocols/geometry/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ def __setitem__(self, key: types.DeckLocation, val: DeckItem) -> None:
self.data[slot_key_int] = val
self._highest_z = max(val.highest_z, self._highest_z)
self._thermocycler_present = any(
isinstance(item, ThermocyclerGeometry) for item in
self.data.values()
isinstance(item, ThermocyclerGeometry) for item in self.data.values()
)

def __contains__(self, key: object) -> bool:
Expand Down
4 changes: 1 addition & 3 deletions api/tests/opentrons/protocols/geometry/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,7 @@ def test_thermocycler_present() -> None:

# Add a thermocycler
deck[7] = module_geometry.load_module(
module_geometry.ThermocyclerModuleModel.THERMOCYCLER_V1,
deck.position_for(7)
module_geometry.ThermocyclerModuleModel.THERMOCYCLER_V1, deck.position_for(7)
)
assert deck.thermocycler_present

Expand All @@ -494,4 +493,3 @@ def test_thermocycler_present() -> None:
# Remove thermocycler
del deck[7]
assert not deck.thermocycler_present

0 comments on commit e3fdba8

Please sign in to comment.