Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initialization of WrappedTreeSequence #760

Merged
merged 1 commit into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/misc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ updates to latest `fwdpp` version, etc.

## Next release

Bug fixes

* Fix error in decoding provenance rows when initializing {class}`fwdpy11.tskit_tools.WrappedTreeSequence`.
{pr}`760`

Dependencies:

* `demes` bumped to `>=0.1.2` in requirements files.
Expand Down
3 changes: 2 additions & 1 deletion fwdpy11/tskit_tools/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with fwdpy11. If not, see <http://www.gnu.org/licenses/>.
#
import json
import typing

import numpy as np
Expand Down Expand Up @@ -47,7 +48,7 @@ def _toplevel_metadata_value(self, name):
def __init__(self, ts: tskit.TreeSequence):
found = False
for row in ts.provenances():
record = eval(row.record)
record = json.loads(row.record)
if "software" in record:
if record["software"]["name"] == "fwdpy11":
found = True
Expand Down
11 changes: 11 additions & 0 deletions tests/test_wrapped_tskit_tree_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#

import fwdpy11
import msprime
import numpy as np
import pytest

Expand Down Expand Up @@ -101,3 +102,13 @@ def test_demes_graph_property(gutenkunst):
ts = pop.dump_tables_to_tskit()
wts = fwdpy11.tskit_tools.WrappedTreeSequence(ts)
assert wts.demes_graph is None


def test_with_msprime_provenance_added():
initial_ts = msprime.sim_ancestry(samples=200, population_size=100, random_seed=1)
pop = fwdpy11.DiploidPopulation.create_from_tskit(initial_ts)
ts = pop.dump_tables_to_tskit()
ts = msprime.sim_mutations(ts, rate=1e-5, random_seed=1)
assert ts.tables.provenances.num_rows == 2
wts = fwdpy11.tskit_tools.WrappedTreeSequence(ts)
assert wts.ts.tables.provenances.num_rows == 2