Skip to content

Commit

Permalink
location of child resources is optional (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickwierenga authored Dec 16, 2024
2 parents 02c6728 + b6ab26f commit c62ea52
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- resource_offset -> pickup_offset
- get_direction -> pickup_direction
- put_direction -> drop_direction
- `location` parameter of `assign_child_resource` is not optional (https://github.com/PyLabRobot/pylabrobot/pull/336)

### Added

Expand Down
2 changes: 1 addition & 1 deletion pylabrobot/liquid_handling/liquid_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ async def move_channel_z(self, channel: int, z: float):
def assign_child_resource(
self,
resource: Resource,
location: Coordinate,
location: Optional[Coordinate],
reassign: bool = True,
):
"""Not implement on LiquidHandler, since the deck is managed by the :attr:`deck` attribute."""
Expand Down
2 changes: 1 addition & 1 deletion pylabrobot/resources/carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def capacity(self):
def assign_child_resource(
self,
resource: Resource,
location: Coordinate,
location: Optional[Coordinate],
reassign: bool = True,
spot: Optional[int] = None,
):
Expand Down
5 changes: 4 additions & 1 deletion pylabrobot/resources/opentrons/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _assign_trash(self):
def assign_child_resource(
self,
resource: Resource,
location: Coordinate,
location: Optional[Coordinate],
reassign: bool = True,
):
"""Assign a resource to a slot.
Expand All @@ -84,6 +84,9 @@ def assign_child_resource(
:meth:`assign_child_at_slot` instead.
"""

if location is None:
raise ValueError("location must be provided for resources on the deck")

if location not in self.slot_locations:
super().assign_child_resource(resource, location=location)
else:
Expand Down
2 changes: 1 addition & 1 deletion pylabrobot/resources/petri_dish.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
def assign_child_resource(
self,
resource: Resource,
location: Coordinate,
location: Optional[Coordinate],
reassign: bool = True,
):
"""Can only assign a single PetriDish"""
Expand Down
4 changes: 2 additions & 2 deletions pylabrobot/resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def get_absolute_size_z(self) -> float:
def assign_child_resource(
self,
resource: Resource,
location: Coordinate,
location: Optional[Coordinate],
reassign: bool = True,
):
"""Assign a child resource to this resource.
Expand All @@ -282,7 +282,7 @@ def assign_child_resource(
Args:
resource: The resource to assign.
location: The location of the resource, relative to this resource.
location: The location of the resource, relative to this resource. None if undefined.
reassign: If `False`, an error will be raised if the resource to be assigned is already
assigned to this resource. Defaults to `True`.
"""
Expand Down

0 comments on commit c62ea52

Please sign in to comment.