Skip to content

Commit f09d404

Browse files
committed
Fix ts unpickling
1 parent f277006 commit f09d404

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

python/CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
**Fixes**
2525

26+
- Tree sequences were not properly init'd after unpickling
27+
(:user:`benjeffery`, :issue:`1297`, :pr:`1298`)
28+
2629
--------------------
2730
[0.3.5] - 2021-03-16
2831
--------------------

python/tests/test_highlevel.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,11 @@ def test_table_metadata_round_trip_via_row_getters(self):
18071807

18081808

18091809
def test_pickle_round_trip(ts_fixture):
1810-
assert ts_fixture.tables == pickle.loads(pickle.dumps(ts_fixture)).tables
1810+
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
1811+
ts = pickle.loads(pickle.dumps(ts_fixture, protocol=protocol))
1812+
assert ts.tables == ts_fixture.tables
1813+
# Do some thing to check the ts is init'd properly
1814+
ts.draw_text()
18111815

18121816

18131817
class TestFileUuid(HighLevelTestCase):

python/tskit/trees.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3315,7 +3315,7 @@ def __getstate__(self):
33153315
return self.dump_tables()
33163316

33173317
def __setstate__(self, tc):
3318-
self._ll_tree_sequence = tc.tree_sequence().ll_tree_sequence
3318+
self.__init__(tc.tree_sequence().ll_tree_sequence)
33193319

33203320
def __eq__(self, other):
33213321
return self.tables == other.tables

0 commit comments

Comments
 (0)