@@ -61,9 +61,7 @@ def _set_liquid_height(
61
61
) -> None :
62
62
"""Set the liquid height of the well."""
63
63
lhi = LiquidHeightInfo (height = height , last_measured = time )
64
- try :
65
- self ._state .measured_liquid_heights [labware_id ]
66
- except KeyError :
64
+ if labware_id not in self ._state .measured_liquid_heights :
67
65
self ._state .measured_liquid_heights [labware_id ] = {}
68
66
self ._state .measured_liquid_heights [labware_id ][well_name ] = lhi
69
67
@@ -83,34 +81,30 @@ def __init__(self, state: WellState) -> None:
83
81
84
82
def get_all (self ) -> List [LiquidHeightSummary ]:
85
83
"""Get all well liquid heights."""
86
- allHeights = [] # type: List[LiquidHeightSummary]
87
- # for key, in self._state.measured_liquid_heights.items():
88
- # lhs = LiquidHeightSummary(labware_id=)
89
- # allHeights.extend(a for a in val.values())
90
- # return allHeights
91
- for labware in self ._state .measured_liquid_heights .keys ():
92
- for well , lhi in self ._state .measured_liquid_heights [labware ].items ():
84
+ all_heights : List [LiquidHeightSummary ] = []
85
+ for labware , wells in self ._state .measured_liquid_heights .items ():
86
+ for well , lhi in wells .items ():
93
87
lhs = LiquidHeightSummary (
94
88
labware_id = labware ,
95
89
well_name = well ,
96
90
height = lhi .height ,
97
91
last_measured = lhi .last_measured ,
98
92
)
99
- allHeights .append (lhs )
100
- return allHeights
93
+ all_heights .append (lhs )
94
+ return all_heights
101
95
102
96
def get_all_in_labware (self , labware_id : str ) -> List [LiquidHeightSummary ]:
103
97
"""Get all well liquid heights for a particular labware."""
104
- allHeights = [] # type: List[LiquidHeightSummary ]
98
+ all_heights : List [ LiquidHeightSummary ] = [ ]
105
99
for well , lhi in self ._state .measured_liquid_heights [labware_id ].items ():
106
100
lhs = LiquidHeightSummary (
107
101
labware_id = labware_id ,
108
102
well_name = well ,
109
103
height = lhi .height ,
110
104
last_measured = lhi .last_measured ,
111
105
)
112
- allHeights .append (lhs )
113
- return allHeights
106
+ all_heights .append (lhs )
107
+ return all_heights
114
108
115
109
def get_last_measured_liquid_height (
116
110
self , labware_id : str , well_name : str
@@ -128,7 +122,8 @@ def get_last_measured_liquid_height(
128
122
def has_measured_liquid_height (self , labware_id : str , well_name : str ) -> bool :
129
123
"""Returns True if the well has been liquid level probed previously."""
130
124
try :
131
- self ._state .measured_liquid_heights [labware_id ][well_name ].height
132
- return True
125
+ return bool (
126
+ self ._state .measured_liquid_heights [labware_id ][well_name ].height
127
+ )
133
128
except KeyError :
134
129
return False
0 commit comments