Skip to content

Commit

Permalink
iteration logic cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CaseyBatten committed Feb 21, 2024
1 parent 90fd772 commit 7fe6dc6
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions api/src/opentrons/protocol_engine/state/tips.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,21 +248,19 @@ def _validate_tip_cluster(tip_cluster: List[str]) -> Optional[str]:
# Move on to the row above or column to the left
if critical_row - num_nozzle_rows > 0:
critical_row = critical_row - num_nozzle_rows
elif critical_column - num_nozzle_cols > 0:
else:
critical_column = critical_column - 1
critical_row = (
len(columns[critical_column]) - num_nozzle_rows
)
else:
critical_column = -1
return None

elif self._state.nozzle_map.starting_nozzle == "A12":
# Define the critical well by the position of the well relative to Tip Rack entry point H1
critical_column = num_nozzle_cols - 1
critical_row = len(columns[critical_column]) - num_nozzle_rows

while critical_column <= 12:
while critical_column <= len(columns): # change to max size of labware
tip_cluster = _identify_tip_cluster(critical_column, critical_row)
result = _validate_tip_cluster(tip_cluster)
if isinstance(result, str):
Expand All @@ -272,13 +270,11 @@ def _validate_tip_cluster(tip_cluster: List[str]) -> Optional[str]:
# Move on to the row above or column to the right
if critical_row - num_nozzle_rows > 0:
critical_row = critical_row - num_nozzle_rows
elif critical_column + num_nozzle_cols < 12:
else:
critical_column = critical_column + 1
critical_row = (
len(columns[critical_column]) - num_nozzle_rows
)
else:
critical_column = 13
return None

elif self._state.nozzle_map.starting_nozzle == "H1":
Expand All @@ -294,35 +290,31 @@ def _validate_tip_cluster(tip_cluster: List[str]) -> Optional[str]:
return result
elif result is None:
# Move on to the row above or column to the right
if critical_row + num_nozzle_rows < 8:
if critical_row + num_nozzle_rows < len(columns[0]):
critical_row = critical_row + num_nozzle_rows
elif critical_column - num_nozzle_cols > 0:
else:
critical_column = critical_column - 1
critical_row = num_nozzle_rows - 1
else:
critical_column = -1
return None

elif self._state.nozzle_map.starting_nozzle == "H12":
# Define the critical well by the position of the well relative to Tip Rack entry point A1
critical_column = num_nozzle_cols - 1
critical_row = num_nozzle_rows - 1

while critical_column <= 12:
while critical_column <= len(columns):
tip_cluster = _identify_tip_cluster(critical_column, critical_row)
result = _validate_tip_cluster(tip_cluster)
if isinstance(result, str):
# The result is the critical tip to target
return result
elif result is None:
# Move on to the row above or column to the right
if critical_row + num_nozzle_rows < 8:
if critical_row + num_nozzle_rows < len(columns[0]):
critical_row = critical_row + num_nozzle_rows
elif critical_column + num_nozzle_cols < 12:
else:
critical_column = critical_column + 1
critical_row = num_nozzle_rows - 1
else:
critical_column = 13
return None

else:
Expand Down

0 comments on commit 7fe6dc6

Please sign in to comment.