Skip to content

Commit

Permalink
Fix bug in string-representation of dilution plans involving serial d…
Browse files Browse the repository at this point in the history
…ilutions (#49)

* Write regression test against #48

* Fix bug in `DilutionPlan` text representation

It affected all text-representation of dilution plans
involving serial dilutions.

Closes #48
  • Loading branch information
michaelosthege authored Nov 7, 2023
1 parent e29fb76 commit 08af830
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
35 changes: 14 additions & 21 deletions notebooks/05_DilutionPlan.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion robotools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
)
from .utils import DilutionPlan, get_trough_wells

__version__ = "1.7.2"
__version__ = "1.7.3"
21 changes: 21 additions & 0 deletions robotools/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ def test_repr(self) -> None:
assert isinstance(out, str)
return

def test_issue_48(self):
"""Columns are named 1-based, therefore the "from column" must be too."""
plan = DilutionPlan(xmin=0.3, xmax=30, stock=30, R=1, C=3, mode="log", vmax=100, min_transfer=10)
np.testing.assert_allclose(plan.x, [[30, 3, 0.3]])
# Reformat instructions for easier equals comparison
instructions = [(col, dsteps, pfrom, float(tvols)) for col, dsteps, pfrom, tvols in plan.instructions]
assert instructions == [
(0, 0, "stock", 100.0),
(1, 0, "stock", 10.0), # The previous column is equal to the stock!
(2, 1, 1, 10.0),
]
plan_s = str(plan)
lines = plan_s.split("\n")
assert "Prepare column 1" in lines[1]
assert "Prepare column 2" in lines[2]
assert "Prepare column 3" in lines[3]
assert "from stock" in lines[1]
assert "from stock" in lines[2]
assert "from column 2" in lines[3]
pass

def test_linear_plan(self) -> None:
plan = DilutionPlan(xmin=1, xmax=10, R=10, C=1, stock=20, mode="linear", vmax=1000, min_transfer=20)

Expand Down
3 changes: 2 additions & 1 deletion robotools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def __repr__(self) -> str:
if dsteps == 0:
output += "stock"
else:
output += f"column {src}"
assert isinstance(src, int)
output += f"column {src + 1}"
output += f" and fill up to {self.vmax[c]} µL"
if dsteps > 0:
output += f" ({dsteps} serial dilutions)"
Expand Down

0 comments on commit 08af830

Please sign in to comment.