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

Example of test failure output; occurs 1/10 times or so #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions devel/occasional_error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /home/jaime/lib/ftprime, inifile: pytest.ini
plugins: cov-2.4.0
collected 6 items

tests/test_forwards_algorithm.py .
tests/test_ftprime_with_simuPOP.py .
tests/test_merge_records_with_wf.py ...F

=================================== FAILURES ===================================
_____________________________ test_simulation_runs _____________________________

def test_simulation_runs():

records = wf(N=5,ngens=5,nsamples=5,survival=0.5)

for x in records.dump_records():
print(x)

samples = [ (0,0) for _ in range(5) ]
> ts = records.tree_sequence(samples=samples)

tests/test_merge_records_with_wf.py:63:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = ARGrecorder([(5, (6, [])), (6, (6, [CoalescenceRecord(left=0.8212435323883007, right=1.0, node=6, children=(12,), time..., population=0)])), (21, (1, [CoalescenceRecord(left=0.0, right=1.0, node=21, children=(1,), time=1, population=0)]))])
samples = [(0, 0), (0, 0), (0, 0), (0, 0), (0, 0)], mutations = None

def tree_sequence(self,samples,mutations=None):
'''
Produce a tree sequence from the ARG.
'''
ts = _msprime.TreeSequence()
ts.load_records(
coalescence_records=list(self.dump_records()),
> samples=samples)
E _msprime.LibraryError: Bad coalescence records in file: Samples must be labeled 0...n-1 and not be internal nodes.

ftprime/argrecorder.py:60: LibraryError
----------------------------- Captured stdout call -----------------------------
t: 0
pop: [5, 6, 7, 8, 9]
10 9 5 1.0
11 9 7 0.0
12 8 6 0.8212435323883007
t: 1
pop: [10, 11, 7, 12, 9]
13 10 9 0.0
14 11 9 0.2806010848256748
15 10 10 0.4513042068306792
t: 2
pop: [10, 11, 13, 14, 15]
16 14 14 0.01065709031372597
17 13 15 0.32783380914661153
t: 3
pop: [10, 11, 13, 16, 17]
18 17 17 0.0
19 10 16 0.6414868623681791
t: 4
pop: [18, 11, 13, 19, 17]
20 19 18 0.10754762965969111
21 11 11 0.0
CoalescenceRecord(left=0.0, right=1.0, node=21, children=(1,), time=1, population=0)
CoalescenceRecord(left=0.0, right=1.0, node=20, children=(3,), time=1, population=0)
CoalescenceRecord(left=0.0, right=0.10754762965969111, node=19, children=(20,), time=2, population=0)
CoalescenceRecord(left=0.0, right=0.10754762965969111, node=18, children=(4,), time=2, population=0)
CoalescenceRecord(left=0.10754762965969111, right=1.0, node=18, children=(4, 20), time=2, population=0)
CoalescenceRecord(left=0.0, right=1.0, node=17, children=(2, 18), time=3, population=0)
CoalescenceRecord(left=0.6414868623681791, right=1.0, node=16, children=(19,), time=3, population=0)
CoalescenceRecord(left=0.32783380914661153, right=1.0, node=15, children=(17,), time=4, population=0)
CoalescenceRecord(left=0.0, right=0.01065709031372597, node=14, children=(16,), time=4, population=0)
CoalescenceRecord(left=0.01065709031372597, right=1.0, node=14, children=(16,), time=4, population=0)
CoalescenceRecord(left=0.0, right=0.32783380914661153, node=13, children=(17,), time=4, population=0)
CoalescenceRecord(left=0.0, right=0.2806010848256748, node=11, children=(0, 14, 21), time=5, population=0)
CoalescenceRecord(left=0.2806010848256748, right=1.0, node=11, children=(0, 21), time=5, population=0)
CoalescenceRecord(left=0.0, right=0.4513042068306792, node=10, children=(15, 19), time=5, population=0)
CoalescenceRecord(left=0.6414868623681791, right=1.0, node=10, children=(15,), time=5, population=0)
CoalescenceRecord(left=0.4513042068306792, right=0.6414868623681791, node=10, children=(15, 19), time=5, population=0)
CoalescenceRecord(left=0.0, right=0.2806010848256748, node=9, children=(10, 13), time=6, population=0)
CoalescenceRecord(left=0.2806010848256748, right=1.0, node=9, children=(10, 13, 14), time=6, population=0)
CoalescenceRecord(left=0.0, right=0.8212435323883007, node=8, children=(12,), time=6, population=0)
CoalescenceRecord(left=0.0, right=1.0, node=7, children=(11,), time=6, population=0)
CoalescenceRecord(left=0.8212435323883007, right=1.0, node=6, children=(12,), time=6, population=0)
====================== 1 failed, 5 passed in 0.19 seconds ======================
4 changes: 2 additions & 2 deletions ftprime/argrecorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def merge_records(new,existing) :
children=children,
time=time,
population=population)
existing[k]=mod_rec
existing[k]=combined_rec
k+=1
existing.insert(k,combined_rec)
existing.insert(k,mod_rec)
k+=1
else:
# print("dangling right")
Expand Down
6 changes: 6 additions & 0 deletions tests/test_merge_records_with_wf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import msprime
from wf import wf

def cr(l,r,n,ch,t,pop=0):
msprime.CoalescenceRecord(left=l, right=r, node=n, children=ch, time=t, population=pop)

def test_1():

new_rec=msprime.CoalescenceRecord(left=0.8, right=1.0, node=18, children=(22,), time=2, population=0)
Expand Down Expand Up @@ -68,3 +71,6 @@ def test_simulation_runs():
print("Mean pairwise diversity:",ts.get_pairwise_diversity())
print("(should be zero)")
assert ts.get_pairwise_diversity() == 0.0

tss=ts.simplify()
assert tss.get_pairwise_diversity() == 0.0
8 changes: 8 additions & 0 deletions tests/wf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def wf(N,ngens,nsamples,survival=0.0) :
records.add_record( left=bp, right=1.0, parent=rparent, children=(offspring,))
# print(records)

# Hackishly, add imaginary entry so smallest internal node is equal to number of samples
for ind in records.keys():
print("ind:",ind)
if len(records[ind][1])>0:
if ind > nsamples:
records.add_record(left=0.0,right=1.0,parent=nsamples,children=(next(labels),))
break

# add phony records that stand in for sampling
samples=random.sample(pop,nsamples)
records.add_samples(samples=samples,length=1.0)
Expand Down