Skip to content

Commit

Permalink
Merge pull request #1906 from petrelharp/print_rates
Browse files Browse the repository at this point in the history
g not f, closes #1905
  • Loading branch information
mergify[bot] authored Nov 12, 2021
2 parents cdc5d99 + cb0ab60 commit 813f6c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion msprime/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def format_row(left, right, mid, span, rate):
f"{right:.10g}",
f"{mid:.10g}",
f"{span:.10g}",
f"{rate:.2f}",
f"{rate:.2g}",
]

def format_slice(start, end):
Expand Down
13 changes: 12 additions & 1 deletion tests/test_intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,22 @@ def test_str(self):
┌──────────────────────────────────┐
│left │right │ mid│ span│ rate│
├──────────────────────────────────┤
│0 │10 │ 5│ 10│ 0.10
│0 │10 │ 5│ 10│ 0.1
└──────────────────────────────────┘
"""
assert textwrap.dedent(s) == str(rate_map)

def test_str_scinot(self):
rate_map = msprime.RateMap(position=[0, 10], rate=[0.000001])
s = """
┌───────────────────────────────────┐
│left │right │ mid│ span│ rate│
├───────────────────────────────────┤
│0 │10 │ 5│ 10│ 1e-06│
└───────────────────────────────────┘
"""
assert textwrap.dedent(s) == str(rate_map)

def test_repr(self):
rate_map = msprime.RateMap(position=[0, 10], rate=[0.1])
s = "RateMap(position=array([ 0., 10.]), rate=array([0.1]))"
Expand Down

0 comments on commit 813f6c5

Please sign in to comment.