Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pylabrobot/resources/volume_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def remove_liquid(self, volume: float) -> List[Tuple[Optional["Liquid"], float]]
"""Remove liquid from the container. Top to bottom."""

available_volume = self.get_used_volume()
if volume > available_volume and abs(volume - available_volume) > 1e-6:
if (volume - available_volume) > 1e-6:
raise TooLittleLiquidError(
f"Container {self.thing} has too little liquid: {volume}uL > {available_volume}uL."
)
Expand All @@ -136,7 +136,7 @@ def remove_liquid(self, volume: float) -> List[Tuple[Optional["Liquid"], float]]
removed_volume += liquid_volume

# If we have more liquid than we need, put the excess back.
if removed_volume > volume and abs(removed_volume - volume) > 1e-6:
if removed_volume > volume:
self.pending_liquids.append((liquid, removed_volume - volume))
removed_liquids.append((liquid, liquid_volume - (removed_volume - volume)))
else:
Expand All @@ -150,7 +150,7 @@ def remove_liquid(self, volume: float) -> List[Tuple[Optional["Liquid"], float]]
def add_liquid(self, liquid: Optional["Liquid"], volume: float) -> None:
"""Add liquid to the container."""

if volume > self.get_free_volume():
if (volume - self.get_free_volume()) > 1e-6:
raise TooLittleVolumeError(
f"Container {self.thing} has too little volume: {volume}uL > {self.get_free_volume()}uL."
)
Expand Down Expand Up @@ -188,7 +188,7 @@ def get_free_volume(self) -> float:
def get_liquids(self, top_volume: float) -> List[Tuple[Optional[Liquid], float]]:
"""Get the liquids in the top `top_volume` uL"""

if top_volume > self.get_used_volume():
if (top_volume - self.get_used_volume()) > 1e-6:
raise TooLittleLiquidError(f"Tracker only has {self.get_used_volume()}uL")

liquids = []
Expand Down