Skip to content

Commit bad0a89

Browse files
authored
Merge pull request #1043 from benjeffery/str-not-repr
Use str instead of repr for terminal use
2 parents 3eaaa93 + aa336a6 commit bad0a89

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

python/CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
- Added ``TreeSequence._repr_html_`` for use in jupyter notebooks.
4545
(:user:`benjeffery`, :issue:`872`, :pr:`923`)
4646

47-
- Added ``TreeSequence.__repr__`` to display a summary for terminal usage.
47+
- Added ``TreeSequence.__str__`` to display a summary for terminal usage.
4848
(:user:`benjeffery`, :issue:`938`, :pr:`985`)
4949

5050
- Added ``TableCollection.dump`` and ``TableCollection.load``. This allows table

python/tests/test_highlevel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,9 +1456,9 @@ def test_html_repr(self):
14561456
for table in ts.tables.name_map:
14571457
assert f"<td>{table.capitalize()}</td>" in html
14581458

1459-
def test_repr(self):
1459+
def test_str(self):
14601460
for ts in get_example_tree_sequences():
1461-
s = repr(ts)
1461+
s = str(ts)
14621462
assert len(s) > 999
14631463
assert re.search(rf"║Trees *│ *{ts.num_trees}║", s)
14641464
for table in ts.tables.name_map:

python/tskit/trees.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3443,7 +3443,7 @@ def dump_text(
34433443
)
34443444
print(row, file=provenances)
34453445

3446-
def __repr__(self):
3446+
def __str__(self):
34473447
ts_rows = [
34483448
["Trees", str(self.num_trees)],
34493449
["Sequence Length", str(self.sequence_length)],

0 commit comments

Comments
 (0)