Skip to content

Commit dc97d25

Browse files
committed
freeze the ops classes and remove doc strings
1 parent 515c8a0 commit dc97d25

File tree

5 files changed

+31
-57
lines changed

5 files changed

+31
-57
lines changed

Diff for: pylabrobot/liquid_handling/backends/hamilton/STAR.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,8 @@ async def aspirate(
15771577
self._assert_valid_resources([op.resource for op in ops])
15781578

15791579
# correct volumes using the liquid class
1580-
for op, hlc in zip(ops, hamilton_liquid_classes):
1581-
op.volume = hlc.compute_corrected_volume(op.volume) if hlc is not None else op.volume
1580+
volumes = [hlc.compute_corrected_volume(op.volume) if hlc is not None else op.volume
1581+
for op, hlc in zip(ops, hamilton_liquid_classes)]
15821582

15831583
well_bottoms = [op.resource.get_absolute_location().z + op.offset.z + \
15841584
op.resource.material_z_thickness for op in ops]
@@ -1657,7 +1657,7 @@ async def aspirate(
16571657
x_positions=x_positions,
16581658
y_positions=y_positions,
16591659

1660-
aspiration_volumes=[round(op.volume * 10) for op in ops],
1660+
aspiration_volumes=[round(vol * 10) for vol in volumes],
16611661
lld_search_height=[round(lsh * 10) for lsh in lld_search_height],
16621662
clot_detection_height=[round(cd * 10) for cd in clot_detection_height],
16631663
liquid_surface_no_lld=[round(ls * 10) for ls in liquid_surfaces_no_lld],
@@ -1839,8 +1839,8 @@ async def dispense(
18391839
))
18401840

18411841
# correct volumes using the liquid class
1842-
for op, hlc in zip(ops, hamilton_liquid_classes):
1843-
op.volume = hlc.compute_corrected_volume(op.volume) if hlc is not None else op.volume
1842+
volumes = [hlc.compute_corrected_volume(op.volume) if hlc is not None else op.volume
1843+
for op, hlc in zip(ops, hamilton_liquid_classes)]
18441844

18451845
well_bottoms = [op.resource.get_absolute_location().z + op.offset.z + \
18461846
op.resource.material_z_thickness for op in ops]
@@ -1858,7 +1858,6 @@ async def dispense(
18581858
[_dispensing_mode_for_op(empty=empty[i], jet=jet[i], blow_out=blow_out[i])
18591859
for i in range(len(ops))]
18601860

1861-
dispense_volumes = [op.volume for op in ops]
18621861
pull_out_distance_transport_air = _fill_in_defaults(pull_out_distance_transport_air, [10.0]*n)
18631862
second_section_height = _fill_in_defaults(second_section_height, [3.2]*n)
18641863
second_section_ratio = _fill_in_defaults(second_section_ratio, [618.0]*n)
@@ -1907,7 +1906,7 @@ async def dispense(
19071906
y_positions=y_positions,
19081907

19091908
dispensing_mode=dispensing_modes,
1910-
dispense_volumes=[round(dv*10) for dv in dispense_volumes],
1909+
dispense_volumes=[round(vol*10) for vol in volumes],
19111910
lld_search_height=[round(lsh*10) for lsh in lld_search_height],
19121911
liquid_surface_no_lld=[round(ls*10) for ls in liquid_surfaces_no_lld],
19131912
pull_out_distance_transport_air=[round(po*10) for po in pull_out_distance_transport_air],

Diff for: pylabrobot/liquid_handling/backends/hamilton/vantage.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,8 @@ async def aspirate(
620620
self._assert_valid_resources([op.resource for op in ops])
621621

622622
# correct volumes using the liquid class
623-
for op, hlc in zip(ops, hlcs):
624-
op.volume = hlc.compute_corrected_volume(op.volume) if hlc is not None else op.volume
623+
volumes = [hlc.compute_corrected_volume(op.volume) if hlc is not None else op.volume
624+
for op, hlc in zip(ops, hlcs)]
625625

626626
well_bottoms = [op.resource.get_absolute_location().z + op.offset.z + \
627627
op.resource.material_z_thickness for op in ops]
@@ -663,7 +663,7 @@ async def aspirate(
663663
immersion_depth=[round(id_*10) for id_ in immersion_depth or [0]*len(ops)],
664664
surface_following_distance=[round(sfd*10) for sfd in surface_following_distance or
665665
[0]*len(ops)],
666-
aspiration_volume=[round(op.volume*100) for op in ops],
666+
aspiration_volume=[round(vol*100) for vol in volumes],
667667
aspiration_speed=[round(fr * 10) for fr in flow_rates],
668668
transport_air_volume=[round(tav*10) for tav in
669669
transport_air_volume or [hlc.aspiration_air_transport_volume if hlc is not None else 0
@@ -785,8 +785,8 @@ async def dispense(
785785
self._assert_valid_resources([op.resource for op in ops])
786786

787787
# correct volumes using the liquid class
788-
for op, hlc in zip(ops, hlcs):
789-
op.volume = hlc.compute_corrected_volume(op.volume) if hlc is not None else op.volume
788+
volumes = [hlc.compute_corrected_volume(op.volume) if hlc is not None else op.volume
789+
for op, hlc in zip(ops, hlcs)]
790790

791791
well_bottoms = [op.resource.get_absolute_location().z + op.offset.z + \
792792
op.resource.material_z_thickness for op in ops]
@@ -831,7 +831,7 @@ async def dispense(
831831
minimal_traverse_height_at_begin_of_command or [self._traversal_height]*len(ops)],
832832
minimal_height_at_command_end=
833833
[round(mh*10) for mh in minimal_height_at_command_end or [self._traversal_height]*len(ops)],
834-
dispense_volume=[round(op.volume * 100) for op in ops],
834+
dispense_volume=[round(vol*100) for vol in volumes],
835835
dispense_speed=[round(fr*10) for fr in flow_rates],
836836
cut_off_speed=[round(cs*10) for cs in cut_off_speed or [250]*len(ops)],
837837
stop_back_volume=[round(sbv*100) for sbv in stop_back_volume or [0]*len(ops)],

Diff for: pylabrobot/liquid_handling/backends/tecan/EVO.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,6 @@ async def aspirate(
317317
tip_type=op.tip.tip_type
318318
) if isinstance(op.tip, TecanTip) else None for op in ops]
319319

320-
for op, tlc in zip(ops, tecan_liquid_classes):
321-
op.volume = tlc.compute_corrected_volume(op.volume) if tlc is not None else op.volume
322-
323320
ys = int(ops[0].resource.get_absolute_size_y() * 10)
324321
zadd: List[Optional[int]] = [0] * self.num_channels
325322
for i, channel in enumerate(use_channels):
@@ -406,11 +403,6 @@ async def dispense(
406403
tip_type=op.tip.tip_type
407404
) if isinstance(op.tip, TecanTip) else None for op in ops]
408405

409-
for op, tlc in zip(ops, tecan_liquid_classes):
410-
op.volume = tlc.compute_corrected_volume(op.volume) + \
411-
tlc.aspirate_lag_volume + tlc.aspirate_tag_volume \
412-
if tlc is not None else op.volume
413-
414406
x, _ = self._first_valid(x_positions)
415407
y, yi = self._first_valid(y_positions)
416408
assert x is not None and y is not None
@@ -724,7 +716,8 @@ def _aspirate_action(
724716
assert tlc is not None and z is not None
725717
sep[channel] = int(tlc.aspirate_speed * 12) # 6?
726718
ssz[channel] = round(z * tlc.aspirate_speed / ops[i].volume)
727-
mtr[channel] = round(ops[i].volume * 6) # 3?
719+
volume = tlc.compute_corrected_volume(ops[i].volume)
720+
mtr[channel] = round(volume * 6) # 3?
728721
ssz_r[channel] = int(tlc.aspirate_retract_speed * 10)
729722

730723
return ssz, sep, stz, mtr, ssz_r
@@ -755,7 +748,9 @@ def _dispense_action(
755748
sep[channel] = int(tlc.dispense_speed * 12) # 6?
756749
spp[channel] = int(tlc.dispense_breakoff * 12) # 6?
757750
stz[channel] = 0
758-
mtr[channel] = -round(ops[i].volume * 6) # 3?
751+
volume = tlc.compute_corrected_volume(ops[i].volume) + tlc.aspirate_lag_volume + \
752+
tlc.aspirate_tag_volume
753+
mtr[channel] = -round(volume * 6) # 3?
759754

760755
return sep, spp, stz, mtr
761756

Diff for: pylabrobot/liquid_handling/backends/tecan/EVO_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ async def test_aspirate(self):
122122
call(module="C5", command="SML", params=[985, 2000, 2000, 2000, 2000, 2000, 2000, 2000]),
123123
call(module="C5", command="SBL", params=[20, None, None, None, None, None, None, None]),
124124
call(module="C5", command="SHZ", params=[1455, 1455, 1455, 1455, 1455, 1455, 1455, 1455]),
125-
call(module="C5", command="MDT", params=[1, None, None, None, 31, 0, 0, 0, 0, 0, 0, 0]),
125+
call(module="C5", command="MDT", params=[1, None, None, None, 30, 0, 0, 0, 0, 0, 0, 0]),
126126
call(module="C5", command="SHZ", params=[2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000]),
127127
call(module="C5", command="SSZ", params=[30, None, None, None, None, None, None, None]),
128128
call(module="C5", command="SEP", params=[1200, None, None, None, None, None, None, None]),
129-
call(module="C5", command="STZ", params=[-31, None, None, None, None, None, None, None]),
129+
call(module="C5", command="STZ", params=[-30, None, None, None, None, None, None, None]),
130130
call(module="C5", command="MTR", params=[626, None, None, None, None, None, None, None]),
131131
call(module="C5", command="SSZ", params=[200, None, None, None, None, None, None, None]),
132132
call(module="C5", command="MAZ", params=[1375, None, None, None, None, None, None, None]),

Diff for: pylabrobot/liquid_handling/standard.py

+12-32
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,34 @@
1414
from pylabrobot.resources.tip_rack import TipSpot
1515

1616

17-
@dataclass
17+
@dataclass(frozen=True)
1818
class Pickup:
19-
""" A pickup operation. """
2019
resource: TipSpot
2120
offset: Coordinate
2221
tip: Tip # TODO: perhaps we can remove this, because the tip spot has the tip?
2322

2423

25-
@dataclass
24+
@dataclass(frozen=True)
2625
class Drop:
27-
""" A drop operation. """
2826
resource: Resource
2927
offset: Coordinate
3028
tip: Tip
3129

3230

33-
@dataclass
31+
@dataclass(frozen=True)
3432
class PickupTipRack:
35-
""" A pickup operation for an entire tip rack. """
36-
3733
resource: TipRack
3834
offset: Coordinate
3935

4036

41-
@dataclass
37+
@dataclass(frozen=True)
4238
class DropTipRack:
43-
""" A drop operation for an entire tip rack. """
44-
4539
resource: Union[TipRack, Trash]
4640
offset: Coordinate
4741

4842

49-
@dataclass
43+
@dataclass(frozen=True)
5044
class Aspiration:
51-
""" Aspiration contains information about an aspiration. """
52-
5345
resource: Container
5446
offset: Coordinate
5547
tip: Tip
@@ -60,10 +52,8 @@ class Aspiration:
6052
liquids: List[Tuple[Optional[Liquid], float]]
6153

6254

63-
@dataclass
55+
@dataclass(frozen=True)
6456
class Dispense:
65-
""" Dispense contains information about an dispense. """
66-
6757
resource: Container
6858
offset: Coordinate
6959
tip: Tip
@@ -74,10 +64,8 @@ class Dispense:
7464
liquids: List[Tuple[Optional[Liquid], float]]
7565

7666

77-
@dataclass
67+
@dataclass(frozen=True)
7868
class AspirationPlate:
79-
""" Contains information about an aspiration from a plate (in a single movement). """
80-
8169
wells: List[Well]
8270
offset: Coordinate
8371
tips: List[Tip]
@@ -88,10 +76,8 @@ class AspirationPlate:
8876
liquids: List[List[Tuple[Optional[Liquid], float]]]
8977

9078

91-
@dataclass
79+
@dataclass(frozen=True)
9280
class DispensePlate:
93-
""" Contains information about an aspiration from a plate (in a single movement). """
94-
9581
wells: List[Well]
9682
offset: Coordinate
9783
tips: List[Tip]
@@ -101,10 +87,8 @@ class DispensePlate:
10187
blow_out_air_volume: Optional[float]
10288
liquids: List[List[Tuple[Optional[Liquid], float]]]
10389

104-
@dataclass
90+
@dataclass(frozen=True)
10591
class AspirationContainer:
106-
""" Contains information about an aspiration from a plate (in a single movement). """
107-
10892
container: Container
10993
offset: Coordinate
11094
tips: List[Tip]
@@ -115,10 +99,8 @@ class AspirationContainer:
11599
liquids: List[List[Tuple[Optional[Liquid], float]]]
116100

117101

118-
@dataclass
102+
@dataclass(frozen=True)
119103
class DispenseContainer:
120-
""" Contains information about an aspiration from a plate (in a single movement). """
121-
122104
container: Container
123105
offset: Coordinate
124106
tips: List[Tip]
@@ -130,17 +112,15 @@ class DispenseContainer:
130112

131113

132114
class GripDirection(enum.Enum):
133-
""" A direction from which to grab the resource. """
134115
FRONT = enum.auto()
135116
BACK = enum.auto()
136117
LEFT = enum.auto()
137118
RIGHT = enum.auto()
138119

139120

140-
@dataclass
121+
@dataclass(frozen=True)
141122
class Move:
142-
""" A move operation.
143-
123+
"""
144124
Attributes:
145125
resource: The resource to move.
146126
destination: The destination of the move.

0 commit comments

Comments
 (0)