Skip to content

Commit 8467a4d

Browse files
tomwhitemergify[bot]
authored andcommitted
Get positions from tskit tables directly (in tests)
1 parent a037a32 commit 8467a4d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sgkit/tests/test_popgen.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def test_diversity__windowed(sample_size):
7676

7777
# Calculate diversity using tskit windows
7878
# Find the variant positions so we can have windows with a fixed number of variants
79-
positions = [variant.site.position for variant in ts.variants()]
80-
windows = [0] + positions[::25][1:] + [ts.sequence_length]
79+
positions = ts.tables.sites.position
80+
windows = np.concatenate(([0], positions[::25][1:], [ts.sequence_length]))
8181
ts_div = ts.diversity(windows=windows, span_normalise=False)
8282
np.testing.assert_allclose(div, ts_div)
8383

@@ -144,8 +144,8 @@ def test_divergence__windowed(sample_size, n_cohorts, chunks):
144144

145145
# Calculate diversity using tskit windows
146146
# Find the variant positions so we can have windows with a fixed number of variants
147-
positions = [variant.site.position for variant in ts.variants()]
148-
windows = [0] + positions[::25][1:] + [ts.sequence_length]
147+
positions = ts.tables.sites.position
148+
windows = np.concatenate(([0], positions[::25][1:], [ts.sequence_length]))
149149
n_windows = len(windows) - 1
150150
ts_div = np.full([n_windows, n_cohorts, n_cohorts], np.nan)
151151
for i, j in itertools.combinations(range(n_cohorts), 2):
@@ -272,8 +272,8 @@ def test_Fst__windowed(sample_size, n_cohorts, chunks):
272272

273273
# Calculate Fst using tskit windows
274274
# Find the variant positions so we can have windows with a fixed number of variants
275-
positions = [variant.site.position for variant in ts.variants()]
276-
windows = [0] + positions[::25][1:] + [ts.sequence_length]
275+
positions = ts.tables.sites.position
276+
windows = np.concatenate(([0], positions[::25][1:], [ts.sequence_length]))
277277
n_windows = len(windows) - 1
278278
ts_fst = np.full([n_windows, n_cohorts, n_cohorts], np.nan)
279279
for i, j in itertools.combinations(range(n_cohorts), 2):

0 commit comments

Comments
 (0)