Skip to content

Commit 9c19027

Browse files
committed
use early raise
1 parent 11b234c commit 9c19027

File tree

1 file changed

+32
-33
lines changed

1 file changed

+32
-33
lines changed

pylabrobot/liquid_handling/liquid_handler.py

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,45 +2587,44 @@ def divide_list_into_chunks(
25872587

25882588
# Only continue if tip_racks are not already consolidated
25892589
if len(target_tip_clusters_by_parent_x) > 0:
2590-
current_tip_model = all_origin_tip_spots[0].tracker.get_tip()
2591-
2592-
# Ensure there are channels that can pick up the tip model
2593-
num_channels_available = len(
2594-
[
2595-
c
2596-
for c in range(self.backend.num_channels)
2597-
if self.backend.can_pick_up_tip(c, current_tip_model)
2598-
]
2599-
)
2590+
raise ValueError(f"No channel capable of handling tips on deck: {current_tip_model}")
26002591

2601-
# 5: Optimise speed
2602-
if num_channels_available > 0:
2603-
# by aggregating drop columns i.e. same drop column should not be visited twice!
2604-
if num_channels_available >= 8: # physical constraint of tip_rack's having 8 rows
2605-
merged_target_tip_clusters = merge_sublists(
2606-
target_tip_clusters_by_parent_x.values(), max_len=8
2607-
)
2592+
current_tip_model = all_origin_tip_spots[0].tracker.get_tip()
26082593

2609-
else: # by chunking drop tip_spots list into size of available channels
2610-
merged_target_tip_clusters = list(
2611-
divide_list_into_chunks(all_target_tip_spots, chunk_size=num_channels_available)
2612-
)
2594+
# Ensure there are channels that can pick up the tip model
2595+
num_channels_available = len(
2596+
[
2597+
c
2598+
for c in range(self.backend.num_channels)
2599+
if self.backend.can_pick_up_tip(c, current_tip_model)
2600+
]
2601+
)
26132602

2614-
len_transfers = len(merged_target_tip_clusters)
2603+
# 5: Optimise speed
2604+
if num_channels_available > 0:
2605+
# by aggregating drop columns i.e. same drop column should not be visited twice!
2606+
if num_channels_available >= 8: # physical constraint of tip_rack's having 8 rows
2607+
merged_target_tip_clusters = merge_sublists(
2608+
target_tip_clusters_by_parent_x.values(), max_len=8
2609+
)
26152610

2616-
# 6: Execute tip movement/consolidation
2617-
for idx, target_tip_spots in enumerate(merged_target_tip_clusters):
2618-
print(f" - tip transfer cycle: {idx} / {len_transfers - 1}")
2619-
num_channels = len(target_tip_spots)
2620-
use_channels = list(range(num_channels))
2611+
else: # by chunking drop tip_spots list into size of available channels
2612+
merged_target_tip_clusters = list(
2613+
divide_list_into_chunks(all_target_tip_spots, chunk_size=num_channels_available)
2614+
)
26212615

2622-
origin_tip_spots = [all_origin_tip_spots.pop(0) for idx in range(num_channels)]
2616+
len_transfers = len(merged_target_tip_clusters)
26232617

2624-
await self.pick_up_tips(origin_tip_spots, use_channels=use_channels)
2618+
# 6: Execute tip movement/consolidation
2619+
for idx, target_tip_spots in enumerate(merged_target_tip_clusters):
2620+
print(f" - tip transfer cycle: {idx} / {len_transfers - 1}")
2621+
num_channels = len(target_tip_spots)
2622+
use_channels = list(range(num_channels))
26252623

2626-
await self.drop_tips(target_tip_spots, use_channels=use_channels)
2627-
else:
2628-
print("Tips already optimally consolidated!")
2624+
origin_tip_spots = [all_origin_tip_spots.pop(0) for idx in range(num_channels)]
26292625

2626+
await self.pick_up_tips(origin_tip_spots, use_channels=use_channels)
2627+
2628+
await self.drop_tips(target_tip_spots, use_channels=use_channels)
26302629
else:
2631-
raise ValueError(f"No channel capable of handling tips on deck: {current_tip_model}")
2630+
print("Tips already optimally consolidated!")

0 commit comments

Comments
 (0)