Skip to content

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
petrelharp committed Jun 22, 2023
2 parents 2fe9f89 + 135a99d commit 68f9aea
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
***************************
[1.0.2] - 2023-06-20
[1.0.3] - 2023-06-21
***************************

**Bugfixes**:
Expand All @@ -17,6 +17,12 @@
are not at the same time as the others. (:user:`petrelharp`, :pr:`308`)


***************************
[1.0.2] - 2023-06-20
***************************

This was a bugfix release that was pushed out without the actual bug fix.
Please don't use this one.

***************************
[1.0.1] - 2022-09-23
Expand Down
2 changes: 1 addition & 1 deletion pyslim/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8
pyslim_version = '1.0.2'
pyslim_version = '1.0.3'
slim_file_version = '0.8'
# other file versions that require no modification
compatible_slim_file_versions = ['0.8']
5 changes: 1 addition & 4 deletions pyslim/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ def recapitate(ts,
# since that's when all the linages are at, and otherwise the event
# won't apply to them
demography.add_population_split(
np.nextafter(
ts.metadata['SLiM']['tick'],
2 * ts.metadata['SLiM']['tick'],
),
np.nextafter( recap_time, 2 * recap_time),
derived=derived_names,
ancestral=ancestral_name,
)
Expand Down
27 changes: 24 additions & 3 deletions tests/test_tree_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import random
import numpy as np
import os
import json

import pytest
import tskit
Expand Down Expand Up @@ -88,7 +89,7 @@ class TestRecapitate(tests.PyslimTestCase):
Tests for recapitation.
'''

def check_recap_consistency(self, ts, recap):
def check_recap_consistency(self, ts, recap, with_ancestral_Ne=True):
assert ts.metadata['SLiM']['tick'] == recap.metadata['SLiM']['tick']
assert ts.metadata['SLiM']['cycle'] == recap.metadata['SLiM']['cycle']
assert ts.metadata['SLiM']['stage'] == recap.metadata['SLiM']['stage']
Expand All @@ -98,6 +99,26 @@ def check_recap_consistency(self, ts, recap):
if ts.has_reference_sequence():
assert ts.reference_sequence.data == recap.reference_sequence.data

root_times = list(set([ts.node(n).time for t in ts.trees() for n in t.roots]))
assert len(root_times) == 1
if with_ancestral_Ne:
# check that time recorded in provenance is correct
assert recap.num_provenances == 2
recap_prov = json.loads(recap.provenance(1).record)
recap_events = recap_prov['parameters']['demography']['events']
assert len(recap_events) == 1
recap_time = recap_events[0]['time']
assert np.allclose(recap_time, root_times[0])
# the oldest nodes in all trees with SLiM provenance should be at that time
if recap.num_nodes <= 500: # takes a long time otherwise
for t in recap.trees():
for n in t.nodes():
rn = recap.node(n)
if rn.metadata is not None:
p = t.parent(n)
if p == tskit.NULL or recap.node(p).metadata is None:
assert rn.time == root_times[0]

ts_samples = list(ts.samples())
for u in recap.samples():
n1 = recap.node(u)
Expand Down Expand Up @@ -218,7 +239,7 @@ def test_with_demography(self, recipe):
extra_metadata={"slim_id": ts.num_populations},
)
demography.add_population_split(
time=ts.metadata["SLiM"]["tick"] + 1.0,
time=ts.metadata["SLiM"]["tick"] + 20.0,
derived=[p.name for p in demography.populations if p.name != "ancestral"],
ancestral="ancestral",
)
Expand All @@ -228,7 +249,7 @@ def test_with_demography(self, recipe):
recombination_rate=recomb_rate,
random_seed=333,
)
self.check_recap_consistency(ts, recap)
self.check_recap_consistency(ts, recap, with_ancestral_Ne=False)

@pytest.mark.parametrize('recipe', recipe_eq(exclude="long"), indirect=True)
def test_first_gen_nodes(self, recipe):
Expand Down

0 comments on commit 68f9aea

Please sign in to comment.