Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromekelleher committed Aug 22, 2023
1 parent 3df491b commit ca5700f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion c/tskit/trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -6516,7 +6516,7 @@ tsk_treeseq_divergence_matrix_branch(const tsk_treeseq_t *self,
double tu, tv, d, span, left, right, span_left, span_right;
double *restrict D;
sv_tables_t sv;
tsk_size_t *ss_offsets = malloc((num_sample_sets + 1) * sizeof(*ss_offsets));
tsk_size_t *ss_offsets = tsk_malloc((num_sample_sets + 1) * sizeof(*ss_offsets));

memset(&sv, 0, sizeof(sv));
ret = tsk_tree_init(&tree, self, 0);
Expand Down
9 changes: 5 additions & 4 deletions python/tests/test_lowlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,10 +1535,13 @@ def test_divergence_matrix(self):
windows = [0, ts.get_sequence_length()]
D = ts.divergence_matrix(windows)
assert D.shape == (1, n, n)
D = ts.divergence_matrix(windows, samples=[0, 1])
D = ts.divergence_matrix(windows, sample_set_sizes=[1, 1], sample_sets=[0, 1])
assert D.shape == (1, 2, 2)
D = ts.divergence_matrix(windows, samples=[0, 1], span_normalise=True)
D = ts.divergence_matrix(
windows, sample_set_sizes=[1, 1], sample_sets=[0, 1], span_normalise=True
)
assert D.shape == (1, 2, 2)
# TODO Add moer tests for sample sets handling
with pytest.raises(TypeError, match="str"):
ts.divergence_matrix(windows, span_normalise="xdf")
with pytest.raises(TypeError):
Expand All @@ -1547,8 +1550,6 @@ def test_divergence_matrix(self):
ts.divergence_matrix(windows=[0])
with pytest.raises(_tskit.LibraryError, match="BAD_WINDOWS"):
ts.divergence_matrix(windows=[-1, 0, 1])
with pytest.raises(ValueError):
ts.divergence_matrix(windows=[0, 1], samples="sdf")
with pytest.raises(ValueError, match="Unrecognised stats mode"):
ts.divergence_matrix(windows=[0, 1], mode="sdf")
with pytest.raises(_tskit.LibraryError, match="UNSUPPORTED_STAT_MODE"):
Expand Down

0 comments on commit ca5700f

Please sign in to comment.