Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Osthege <m.osthege@fz-juelich.de>
  • Loading branch information
Y0dler and michaelosthege authored Jan 24, 2023
1 parent 20f4a92 commit bca93a1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions robotools/evotools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,19 @@ def _prepare_evo_aspirate_dispense_parameters(
raise Exception(
f"Invalid volume: Tips, wells, and volume lists have different lengths ({len(tips)}, {len(wells)} and {len(volume)}, respectively)."
)
elif type(volume) == float or type(volume) == int:
elif isinstance(volume, (float, int)):
# test volume like in the list section
if volume < 0 or volume > 7158278 or numpy.isnan(volume):
raise ValueError(f"Invalid volume: {volume}")
if max_volume is not None and volume > max_volume:
raise InvalidOperationError(f"Invalid volume: volume of {volume} exceeds max_volume.")
# convert volume to list and multiply list to reach identical length as wells
volume = [float(volume)]
volume = volume * len(wells)
volume = [float(volume)] * len(wells)
else:
raise ValueError(f"Invalid volume: {volume}")

# apply rounding and corrections for the right string formatting
volume = [numpy.round(vol, decimals=2) for vol in volume]
volume = numpy.round(volume, decimals=2).tolist()

if liquid_class is None:
raise ValueError(f"Missing required parameter: liquid_class")
Expand All @@ -283,7 +282,7 @@ def _prepare_evo_aspirate_dispense_parameters(
if tips is None:
raise ValueError(f"Missing required parameter: tips")
for tip in tips:
if type(tip) is not int and type(tip) is not Tip:
if not isinstance(tip, (int, Tip)):
raise ValueError(f"Invalid type of tips: {type(tip)}. Has to be int or Tip.")
tecan_tips = []
for tip in tips:
Expand Down

0 comments on commit bca93a1

Please sign in to comment.