@@ -668,10 +668,12 @@ def test_short_sequence_length(self):
668
668
669
669
@pytest .mark .slow
670
670
def test_wright_fisher_slow (self , wf_fixture_slow ):
671
- self .verify (wf_fixture_slow )
671
+ _ , ts = wf_fixture_slow
672
+ self .verify (ts )
672
673
673
674
def test_wright_fisher (self , wf_fixture ):
674
- self .verify (wf_fixture )
675
+ _ , ts = wf_fixture
676
+ self .verify (ts )
675
677
676
678
def test_empty_ts (self ):
677
679
tables = tskit .TableCollection (1.0 )
@@ -827,13 +829,13 @@ def wf_fixture_sims():
827
829
)
828
830
def wf_fixture (wf_fixture_sims , request ):
829
831
"""
830
- A collection of small Wright-Fisher simulations.
832
+ A collection of small Wright-Fisher simulations. The name is returned for
833
+ debugging purposes.
831
834
"""
832
- ts = msprime .sim_mutations (
833
- wf_fixture_sims [request .param ], rate = 0.05 , random_seed = 1234
834
- )
835
+ name = request .param
836
+ ts = msprime .sim_mutations (wf_fixture_sims [name ], rate = 0.05 , random_seed = 1234 )
835
837
assert ts .num_mutations > 0
836
- return ts
838
+ return name , ts
837
839
838
840
839
841
@pytest .fixture (params = ["unsimplified" , "initial_generation" ], scope = "session" )
@@ -842,11 +844,10 @@ def wf_fixture_slow(wf_fixture_sims, request):
842
844
A few more small Wright-Fisher simulations. Despite the name, in total
843
845
they take about the same time for tests together as wf_fixture.
844
846
"""
845
- ts = msprime .sim_mutations (
846
- wf_fixture_sims [request .param ], rate = 0.05 , random_seed = 1234
847
- )
847
+ name = request .param
848
+ ts = msprime .sim_mutations (wf_fixture_sims [name ], rate = 0.05 , random_seed = 1234 )
848
849
assert ts .num_mutations > 0
849
- return ts
850
+ return name , ts
850
851
851
852
852
853
@pytest .fixture (scope = "session" )
@@ -1107,12 +1108,12 @@ def test_many_trees_sequence_length_infinite_sites(
1107
1108
self .verify (ts )
1108
1109
1109
1110
def test_wright_fisher (self , wf_fixture ):
1110
- ts = wf_fixture
1111
+ _ , ts = wf_fixture
1111
1112
assert ts .num_sites > 0
1112
1113
self .verify (ts )
1113
1114
1114
1115
def test_wright_fisher_slow (self , wf_fixture_slow ):
1115
- ts = wf_fixture_slow
1116
+ _ , ts = wf_fixture_slow
1116
1117
assert ts .num_sites > 0
1117
1118
self .verify (ts )
1118
1119
@@ -1130,7 +1131,7 @@ def example_sample_sets(ts, min_size=1):
1130
1131
number of sample sets returned in each example must be at least min_size
1131
1132
"""
1132
1133
samples = ts .samples ()
1133
- np .random .shuffle (samples )
1134
+ np .random .shuffle (samples ) # <-- no seed
1134
1135
splits = np .array_split (samples , min_size )
1135
1136
yield splits
1136
1137
yield [[s ] for s in samples ]
@@ -1748,6 +1749,12 @@ def verify_persite_tajimas_d(self, ts, sample_sets):
1748
1749
sigma1 = ts .Tajimas_D (sample_sets , windows = windows , mode = self .mode )
1749
1750
sigma2 = site_tajimas_d (ts , sample_sets , windows = windows )
1750
1751
assert sigma1 .shape == sigma2 .shape
1752
+ # floating point error can lead in strange cases to
1753
+ # +/-inf in our implementation here and nan in the ts version
1754
+ f1 = np .isfinite (sigma1 )
1755
+ f2 = np .isfinite (sigma2 )
1756
+ assert np .all (f1 == f2 )
1757
+ sigma2 [~ f2 ] = np .nan
1751
1758
self .assertArrayAlmostEqual (sigma1 , sigma2 )
1752
1759
1753
1760
0 commit comments