Skip to content

Commit 0ed604c

Browse files
addressing comments
1 parent 3b8fd27 commit 0ed604c

File tree

1 file changed

+12
-17
lines changed
  • api/src/opentrons/protocol_engine/state

1 file changed

+12
-17
lines changed

api/src/opentrons/protocol_engine/state/wells.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def _set_liquid_height(
6161
) -> None:
6262
"""Set the liquid height of the well."""
6363
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:
6765
self._state.measured_liquid_heights[labware_id] = {}
6866
self._state.measured_liquid_heights[labware_id][well_name] = lhi
6967

@@ -83,34 +81,30 @@ def __init__(self, state: WellState) -> None:
8381

8482
def get_all(self) -> List[LiquidHeightSummary]:
8583
"""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():
9387
lhs = LiquidHeightSummary(
9488
labware_id=labware,
9589
well_name=well,
9690
height=lhi.height,
9791
last_measured=lhi.last_measured,
9892
)
99-
allHeights.append(lhs)
100-
return allHeights
93+
all_heights.append(lhs)
94+
return all_heights
10195

10296
def get_all_in_labware(self, labware_id: str) -> List[LiquidHeightSummary]:
10397
"""Get all well liquid heights for a particular labware."""
104-
allHeights = [] # type: List[LiquidHeightSummary]
98+
all_heights: List[LiquidHeightSummary] = []
10599
for well, lhi in self._state.measured_liquid_heights[labware_id].items():
106100
lhs = LiquidHeightSummary(
107101
labware_id=labware_id,
108102
well_name=well,
109103
height=lhi.height,
110104
last_measured=lhi.last_measured,
111105
)
112-
allHeights.append(lhs)
113-
return allHeights
106+
all_heights.append(lhs)
107+
return all_heights
114108

115109
def get_last_measured_liquid_height(
116110
self, labware_id: str, well_name: str
@@ -128,7 +122,8 @@ def get_last_measured_liquid_height(
128122
def has_measured_liquid_height(self, labware_id: str, well_name: str) -> bool:
129123
"""Returns True if the well has been liquid level probed previously."""
130124
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+
)
133128
except KeyError:
134129
return False

0 commit comments

Comments
 (0)