Skip to content

Commit 18a10d3

Browse files
linx5orickwierenga
andauthored
Update default values in STARBackend to use floats instead of integers (#586)
Co-authored-by: Rick Wierenga <rick_wierenga@icloud.com>
1 parent 059e368 commit 18a10d3

File tree

1 file changed

+31
-36
lines changed

1 file changed

+31
-36
lines changed

pylabrobot/liquid_handling/backends/hamilton/STAR_backend.py

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -106,23 +106,14 @@ async def wrapper(self: "STAR", *args, **kwargs):
106106

107107
def _fill_in_defaults(val: Optional[List[T]], default: List[T]) -> List[T]:
108108
"""Util for converting an argument to the appropriate format for low level star methods."""
109-
t = type(default[0])
110109
# if the val is None, use the default.
111110
if val is None:
112111
return default
113-
# repeat val if it is not a list.
114-
if not isinstance(val, list):
115-
return [val] * len(default)
116112
# if the val is a list, it must be of the correct length.
117113
if len(val) != len(default):
118114
raise ValueError(f"Value length must equal num operations ({len(default)}), but is {val}")
119115
# replace None values in list with default values.
120116
val = [v if v is not None else d for v, d in zip(val, default)]
121-
# the values must be of the right type. automatically handle int and float.
122-
if t in [int, float]:
123-
return [t(v) for v in val] # type: ignore
124-
if not all(isinstance(v, t) for v in val):
125-
raise ValueError(f"Value must be a list of {t}, but is {val}")
126117
# the value is ready to be used.
127118
return val
128119

@@ -1763,7 +1754,7 @@ async def aspirate(
17631754
clot_detection_height = _fill_in_defaults(
17641755
clot_detection_height,
17651756
default=[
1766-
hlc.aspiration_clot_retract_height if hlc is not None else 0
1757+
hlc.aspiration_clot_retract_height if hlc is not None else 0.0
17671758
for hlc in hamilton_liquid_classes
17681759
],
17691760
)
@@ -1772,61 +1763,63 @@ async def aspirate(
17721763
second_section_ratio = _fill_in_defaults(second_section_ratio, [618.0] * n)
17731764
minimum_height = _fill_in_defaults(minimum_height, well_bottoms)
17741765
# TODO: I think minimum height should be the minimum height of the well
1775-
immersion_depth = _fill_in_defaults(immersion_depth, [0] * n)
1766+
immersion_depth = _fill_in_defaults(immersion_depth, [0.0] * n)
17761767
immersion_depth_direction = _fill_in_defaults(immersion_depth_direction, [0] * n)
1777-
surface_following_distance = _fill_in_defaults(surface_following_distance, [0] * n)
1768+
surface_following_distance = _fill_in_defaults(surface_following_distance, [0.0] * n)
17781769
flow_rates = [
1779-
op.flow_rate or (hlc.aspiration_flow_rate if hlc is not None else 100)
1770+
op.flow_rate or (hlc.aspiration_flow_rate if hlc is not None else 100.0)
17801771
for op, hlc in zip(ops, hamilton_liquid_classes)
17811772
]
17821773
transport_air_volume = _fill_in_defaults(
17831774
transport_air_volume,
17841775
default=[
1785-
hlc.aspiration_air_transport_volume if hlc is not None else 0
1776+
hlc.aspiration_air_transport_volume if hlc is not None else 0.0
17861777
for hlc in hamilton_liquid_classes
17871778
],
17881779
)
17891780
blow_out_air_volumes = [
1790-
(op.blow_out_air_volume or (hlc.aspiration_blow_out_volume if hlc is not None else 0))
1781+
(op.blow_out_air_volume or (hlc.aspiration_blow_out_volume if hlc is not None else 0.0))
17911782
for op, hlc in zip(ops, hamilton_liquid_classes)
17921783
]
1793-
pre_wetting_volume = _fill_in_defaults(pre_wetting_volume, [0] * n)
1784+
pre_wetting_volume = _fill_in_defaults(pre_wetting_volume, [0.0] * n)
17941785
lld_mode = _fill_in_defaults(lld_mode, [self.__class__.LLDMode.OFF] * n)
17951786
gamma_lld_sensitivity = _fill_in_defaults(gamma_lld_sensitivity, [1] * n)
17961787
dp_lld_sensitivity = _fill_in_defaults(dp_lld_sensitivity, [1] * n)
17971788
aspirate_position_above_z_touch_off = _fill_in_defaults(
1798-
aspirate_position_above_z_touch_off, [0] * n
1789+
aspirate_position_above_z_touch_off, [0.0] * n
17991790
)
18001791
detection_height_difference_for_dual_lld = _fill_in_defaults(
1801-
detection_height_difference_for_dual_lld, [0] * n
1792+
detection_height_difference_for_dual_lld, [0.0] * n
18021793
)
18031794
swap_speed = _fill_in_defaults(
18041795
swap_speed,
18051796
default=[
1806-
hlc.aspiration_swap_speed if hlc is not None else 100 for hlc in hamilton_liquid_classes
1797+
hlc.aspiration_swap_speed if hlc is not None else 100.0 for hlc in hamilton_liquid_classes
18071798
],
18081799
)
18091800
settling_time = _fill_in_defaults(
18101801
settling_time,
18111802
default=[
1812-
hlc.aspiration_settling_time if hlc is not None else 0 for hlc in hamilton_liquid_classes
1803+
hlc.aspiration_settling_time if hlc is not None else 0.0 for hlc in hamilton_liquid_classes
18131804
],
18141805
)
1815-
mix_volume = _fill_in_defaults(mix_volume, [0] * n)
1806+
mix_volume = _fill_in_defaults(mix_volume, [0.0] * n)
18161807
mix_cycles = _fill_in_defaults(mix_cycles, [0] * n)
1817-
mix_position_from_liquid_surface = _fill_in_defaults(mix_position_from_liquid_surface, [0] * n)
1808+
mix_position_from_liquid_surface = _fill_in_defaults(
1809+
mix_position_from_liquid_surface, [0.0] * n
1810+
)
18181811
mix_speed = _fill_in_defaults(
18191812
mix_speed,
18201813
default=[
18211814
hlc.aspiration_mix_flow_rate if hlc is not None else 50.0 for hlc in hamilton_liquid_classes
18221815
],
18231816
)
1824-
mix_surface_following_distance = _fill_in_defaults(mix_surface_following_distance, [0] * n)
1817+
mix_surface_following_distance = _fill_in_defaults(mix_surface_following_distance, [0.0] * n)
18251818
limit_curve_index = _fill_in_defaults(limit_curve_index, [0] * n)
18261819

18271820
use_2nd_section_aspiration = _fill_in_defaults(use_2nd_section_aspiration, [False] * n)
18281821
retract_height_over_2nd_section_to_empty_tip = _fill_in_defaults(
1829-
retract_height_over_2nd_section_to_empty_tip, [0] * n
1822+
retract_height_over_2nd_section_to_empty_tip, [0.0] * n
18301823
)
18311824
dispensation_speed_during_emptying_tip = _fill_in_defaults(
18321825
dispensation_speed_during_emptying_tip, [50.0] * n
@@ -1837,9 +1830,9 @@ async def aspirate(
18371830
z_drive_speed_during_2nd_section_search = _fill_in_defaults(
18381831
z_drive_speed_during_2nd_section_search, [30.0] * n
18391832
)
1840-
cup_upper_edge = _fill_in_defaults(cup_upper_edge, [0] * n)
1833+
cup_upper_edge = _fill_in_defaults(cup_upper_edge, [0.0] * n)
18411834
ratio_liquid_rise_to_tip_deep_in = _fill_in_defaults(ratio_liquid_rise_to_tip_deep_in, [0] * n)
1842-
immersion_depth_2nd_section = _fill_in_defaults(immersion_depth_2nd_section, [0] * n)
1835+
immersion_depth_2nd_section = _fill_in_defaults(immersion_depth_2nd_section, [0.0] * n)
18431836

18441837
try:
18451838
return await self.aspirate_pip(
@@ -2063,29 +2056,29 @@ async def dispense(
20632056
second_section_height = _fill_in_defaults(second_section_height, [3.2] * n)
20642057
second_section_ratio = _fill_in_defaults(second_section_ratio, [618.0] * n)
20652058
minimum_height = _fill_in_defaults(minimum_height, well_bottoms)
2066-
immersion_depth = _fill_in_defaults(immersion_depth, [0] * n)
2059+
immersion_depth = _fill_in_defaults(immersion_depth, [0.0] * n)
20672060
immersion_depth_direction = _fill_in_defaults(immersion_depth_direction, [0] * n)
2068-
surface_following_distance = _fill_in_defaults(surface_following_distance, [0] * n)
2061+
surface_following_distance = _fill_in_defaults(surface_following_distance, [0.0] * n)
20692062
flow_rates = [
2070-
op.flow_rate or (hlc.dispense_flow_rate if hlc is not None else 120)
2063+
op.flow_rate or (hlc.dispense_flow_rate if hlc is not None else 120.0)
20712064
for op, hlc in zip(ops, hamilton_liquid_classes)
20722065
]
20732066
cut_off_speed = _fill_in_defaults(cut_off_speed, [5.0] * n)
20742067
stop_back_volume = _fill_in_defaults(
20752068
stop_back_volume,
20762069
default=[
2077-
hlc.dispense_stop_back_volume if hlc is not None else 0 for hlc in hamilton_liquid_classes
2070+
hlc.dispense_stop_back_volume if hlc is not None else 0.0 for hlc in hamilton_liquid_classes
20782071
],
20792072
)
20802073
transport_air_volume = _fill_in_defaults(
20812074
transport_air_volume,
20822075
default=[
2083-
hlc.dispense_air_transport_volume if hlc is not None else 0
2076+
hlc.dispense_air_transport_volume if hlc is not None else 0.0
20842077
for hlc in hamilton_liquid_classes
20852078
],
20862079
)
20872080
blow_out_air_volumes = [
2088-
(op.blow_out_air_volume or (hlc.dispense_blow_out_volume if hlc is not None else 0))
2081+
(op.blow_out_air_volume or (hlc.dispense_blow_out_volume if hlc is not None else 0.0))
20892082
for op, hlc in zip(ops, hamilton_liquid_classes)
20902083
]
20912084
lld_mode = _fill_in_defaults(lld_mode, [self.__class__.LLDMode.OFF] * n)
@@ -2103,19 +2096,21 @@ async def dispense(
21032096
settling_time = _fill_in_defaults(
21042097
settling_time,
21052098
default=[
2106-
hlc.dispense_settling_time if hlc is not None else 0 for hlc in hamilton_liquid_classes
2099+
hlc.dispense_settling_time if hlc is not None else 0.0 for hlc in hamilton_liquid_classes
21072100
],
21082101
)
2109-
mix_volume = _fill_in_defaults(mix_volume, [0] * n)
2102+
mix_volume = _fill_in_defaults(mix_volume, [0.0] * n)
21102103
mix_cycles = _fill_in_defaults(mix_cycles, [0] * n)
2111-
mix_position_from_liquid_surface = _fill_in_defaults(mix_position_from_liquid_surface, [0] * n)
2104+
mix_position_from_liquid_surface = _fill_in_defaults(
2105+
mix_position_from_liquid_surface, [0.0] * n
2106+
)
21122107
mix_speed = _fill_in_defaults(
21132108
mix_speed,
21142109
default=[
21152110
hlc.dispense_mix_flow_rate if hlc is not None else 50.0 for hlc in hamilton_liquid_classes
21162111
],
21172112
)
2118-
mix_surface_following_distance = _fill_in_defaults(mix_surface_following_distance, [0] * n)
2113+
mix_surface_following_distance = _fill_in_defaults(mix_surface_following_distance, [0.0] * n)
21192114
limit_curve_index = _fill_in_defaults(limit_curve_index, [0] * n)
21202115

21212116
try:

0 commit comments

Comments
 (0)