Skip to content

Commit 801def0

Browse files
Fix some packageing issues
1 parent 6021505 commit 801def0

4 files changed

Lines changed: 54 additions & 65 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include lwt_interface/*.h
12
include lib/*.h
23
include lib/subprojects/tskit/c/*.h
34
include lib/subprojects/tskit/c/tskit/*.h

_tsinfermodule.c

Lines changed: 47 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,21 +1661,20 @@ static PyTypeObject AncestorMatcherType = {
16611661
(initproc) AncestorMatcher_init, /* tp_init */
16621662
};
16631663

1664-
16651664
/*===================================================================
16661665
* MatcherIndexes
16671666
*===================================================================
16681667
*/
16691668

16701669
static void
1671-
MatcherIndexes_dealloc(MatcherIndexes* self)
1670+
MatcherIndexes_dealloc(MatcherIndexes *self)
16721671
{
16731672
if (self->matcher_indexes != NULL) {
16741673
/* matcher_indexes_free(self->matcher_indexes); */
16751674
PyMem_Free(self->matcher_indexes);
16761675
self->matcher_indexes = NULL;
16771676
}
1678-
Py_TYPE(self)->tp_free((PyObject*)self);
1677+
Py_TYPE(self)->tp_free((PyObject *) self);
16791678
}
16801679

16811680
static int
@@ -1684,11 +1683,11 @@ MatcherIndexes_init(MatcherIndexes *self, PyObject *args, PyObject *kwds)
16841683
int ret = -1;
16851684
int err;
16861685
LightweightTableCollection *tables;
1687-
static char *kwlist[] = {"tables", NULL};
1686+
static char *kwlist[] = { "tables", NULL };
16881687

16891688
self->matcher_indexes = NULL;
1690-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist,
1691-
&LightweightTableCollectionType, &tables)) {
1689+
if (!PyArg_ParseTupleAndKeywords(
1690+
args, kwds, "O!", kwlist, &LightweightTableCollectionType, &tables)) {
16921691
goto out;
16931692
}
16941693
if (LightweightTableCollection_check_state(tables) != 0) {
@@ -1721,7 +1720,6 @@ MatcherIndexes_check_state(MatcherIndexes *self)
17211720
return ret;
17221721
}
17231722

1724-
17251723
static PyObject *
17261724
MatcherIndexes_print_state(MatcherIndexes *self, PyObject *args)
17271725
{
@@ -1748,11 +1746,10 @@ MatcherIndexes_print_state(MatcherIndexes *self, PyObject *args)
17481746
return ret;
17491747
}
17501748

1751-
17521749
static PyMethodDef MatcherIndexes_methods[] = {
1753-
{"print_state", (PyCFunction) MatcherIndexes_print_state,
1754-
METH_VARARGS, "Low-level debug method"},
1755-
{NULL} /* Sentinel */
1750+
{ "print_state", (PyCFunction) MatcherIndexes_print_state, METH_VARARGS,
1751+
"Low-level debug method" },
1752+
{ NULL } /* Sentinel */
17561753
};
17571754

17581755
static PyTypeObject MatcherIndexesType = {
@@ -1769,7 +1766,6 @@ static PyTypeObject MatcherIndexesType = {
17691766
// clang-format on
17701767
};
17711768

1772-
17731769
/*===================================================================
17741770
* AncestorMatcher2
17751771
*===================================================================
@@ -1787,15 +1783,15 @@ AncestorMatcher2_check_state(AncestorMatcher2 *self)
17871783
}
17881784

17891785
static void
1790-
AncestorMatcher2_dealloc(AncestorMatcher2* self)
1786+
AncestorMatcher2_dealloc(AncestorMatcher2 *self)
17911787
{
17921788
if (self->ancestor_matcher != NULL) {
17931789
ancestor_matcher2_free(self->ancestor_matcher);
17941790
PyMem_Free(self->ancestor_matcher);
17951791
self->ancestor_matcher = NULL;
17961792
}
17971793
Py_XDECREF(self->matcher_indexes);
1798-
Py_TYPE(self)->tp_free((PyObject*)self);
1794+
Py_TYPE(self)->tp_free((PyObject *) self);
17991795
}
18001796

18011797
static int
@@ -1804,8 +1800,8 @@ AncestorMatcher2_init(AncestorMatcher2 *self, PyObject *args, PyObject *kwds)
18041800
int ret = -1;
18051801
int err;
18061802
int extended_checks = 0;
1807-
static char *kwlist[] = {"matcher_indexes", "recombination",
1808-
"mismatch", "precision", "extended_checks", NULL};
1803+
static char *kwlist[] = { "matcher_indexes", "recombination", "mismatch",
1804+
"precision", "extended_checks", NULL };
18091805
MatcherIndexes *matcher_indexes = NULL;
18101806
PyObject *recombination = NULL;
18111807
PyObject *mismatch = NULL;
@@ -1817,10 +1813,8 @@ AncestorMatcher2_init(AncestorMatcher2 *self, PyObject *args, PyObject *kwds)
18171813

18181814
self->ancestor_matcher = NULL;
18191815
self->matcher_indexes = NULL;
1820-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!OO|Ii", kwlist,
1821-
&MatcherIndexesType, &matcher_indexes,
1822-
&recombination, &mismatch, &precision,
1823-
&extended_checks)) {
1816+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!OO|Ii", kwlist, &MatcherIndexesType,
1817+
&matcher_indexes, &recombination, &mismatch, &precision, &extended_checks)) {
18241818
goto out;
18251819
}
18261820
self->matcher_indexes = matcher_indexes;
@@ -1830,20 +1824,18 @@ AncestorMatcher2_init(AncestorMatcher2 *self, PyObject *args, PyObject *kwds)
18301824
}
18311825

18321826
recombination_array = (PyArrayObject *) PyArray_FromAny(recombination,
1833-
PyArray_DescrFromType(NPY_FLOAT64), 1, 1,
1834-
NPY_ARRAY_IN_ARRAY, NULL);
1827+
PyArray_DescrFromType(NPY_FLOAT64), 1, 1, NPY_ARRAY_IN_ARRAY, NULL);
18351828
if (recombination_array == NULL) {
18361829
goto out;
18371830
}
18381831
shape = PyArray_DIMS(recombination_array);
18391832
if (shape[0] != (npy_intp) matcher_indexes->matcher_indexes->num_sites) {
1840-
PyErr_SetString(PyExc_ValueError,
1841-
"Size of recombination array must be num_sites");
1833+
PyErr_SetString(
1834+
PyExc_ValueError, "Size of recombination array must be num_sites");
18421835
goto out;
18431836
}
1844-
mismatch_array = (PyArrayObject *) PyArray_FromAny(mismatch,
1845-
PyArray_DescrFromType(NPY_FLOAT64), 1, 1,
1846-
NPY_ARRAY_IN_ARRAY, NULL);
1837+
mismatch_array = (PyArrayObject *) PyArray_FromAny(
1838+
mismatch, PyArray_DescrFromType(NPY_FLOAT64), 1, 1, NPY_ARRAY_IN_ARRAY, NULL);
18471839
if (mismatch_array == NULL) {
18481840
goto out;
18491841
}
@@ -1862,10 +1854,8 @@ AncestorMatcher2_init(AncestorMatcher2 *self, PyObject *args, PyObject *kwds)
18621854
flags = TSI_EXTENDED_CHECKS;
18631855
}
18641856
err = ancestor_matcher2_alloc(self->ancestor_matcher,
1865-
self->matcher_indexes->matcher_indexes,
1866-
PyArray_DATA(recombination_array),
1867-
PyArray_DATA(mismatch_array),
1868-
precision, flags);
1857+
self->matcher_indexes->matcher_indexes, PyArray_DATA(recombination_array),
1858+
PyArray_DATA(mismatch_array), precision, flags);
18691859
if (err != 0) {
18701860
handle_library_error(err);
18711861
goto out;
@@ -1882,7 +1872,7 @@ AncestorMatcher2_find_path(AncestorMatcher2 *self, PyObject *args, PyObject *kwd
18821872
{
18831873
int err;
18841874
PyObject *ret = NULL;
1885-
static char *kwlist[] = {"haplotype", "start", "end", NULL};
1875+
static char *kwlist[] = { "haplotype", "start", "end", NULL };
18861876
PyObject *haplotype = NULL;
18871877
PyArrayObject *haplotype_array = NULL;
18881878
npy_intp *shape;
@@ -1897,12 +1887,12 @@ AncestorMatcher2_find_path(AncestorMatcher2 *self, PyObject *args, PyObject *kwd
18971887
if (AncestorMatcher2_check_state(self) != 0) {
18981888
goto out;
18991889
}
1900-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oii", kwlist,
1901-
&haplotype, &start, &end)) {
1890+
if (!PyArg_ParseTupleAndKeywords(
1891+
args, kwds, "Oii", kwlist, &haplotype, &start, &end)) {
19021892
goto out;
19031893
}
1904-
haplotype_array = (PyArrayObject *) PyArray_FROM_OTF(haplotype, NPY_INT8,
1905-
NPY_ARRAY_IN_ARRAY);
1894+
haplotype_array
1895+
= (PyArrayObject *) PyArray_FROM_OTF(haplotype, NPY_INT8, NPY_ARRAY_IN_ARRAY);
19061896
if (haplotype_array == NULL) {
19071897
goto out;
19081898
}
@@ -1926,16 +1916,17 @@ AncestorMatcher2_find_path(AncestorMatcher2 *self, PyObject *args, PyObject *kwd
19261916
}
19271917

19281918
Py_BEGIN_ALLOW_THREADS
1929-
err = ancestor_matcher2_find_path(self->ancestor_matcher,
1930-
(tsk_id_t) start, (tsk_id_t) end, (allele_t *) PyArray_DATA(haplotype_array),
1931-
(allele_t *) PyArray_DATA(match),
1932-
&num_edges, PyArray_DATA(left), PyArray_DATA(right), PyArray_DATA(parent));
1919+
err = ancestor_matcher2_find_path(self->ancestor_matcher, (tsk_id_t) start,
1920+
(tsk_id_t) end, (allele_t *) PyArray_DATA(haplotype_array),
1921+
(allele_t *) PyArray_DATA(match), &num_edges, PyArray_DATA(left),
1922+
PyArray_DATA(right), PyArray_DATA(parent));
19331923
Py_END_ALLOW_THREADS
19341924
if (err != 0) {
19351925
handle_library_error(err);
19361926
goto out;
19371927
}
1938-
ret = Py_BuildValue("(kOOOO)", (unsigned long) num_edges, left, right, parent, match);
1928+
ret = Py_BuildValue(
1929+
"(kOOOO)", (unsigned long) num_edges, left, right, parent, match);
19391930
if (ret == NULL) {
19401931
goto out;
19411932
}
@@ -2008,8 +1999,8 @@ AncestorMatcher2_get_mean_traceback_size(AncestorMatcher2 *self, void *closure)
20081999
if (AncestorMatcher2_check_state(self) != 0) {
20092000
goto out;
20102001
}
2011-
ret = Py_BuildValue("d", ancestor_matcher2_get_mean_traceback_size(
2012-
self->ancestor_matcher));
2002+
ret = Py_BuildValue(
2003+
"d", ancestor_matcher2_get_mean_traceback_size(self->ancestor_matcher));
20132004
out:
20142005
return ret;
20152006
}
@@ -2022,31 +2013,29 @@ AncestorMatcher2_get_total_memory(AncestorMatcher2 *self, void *closure)
20222013
if (AncestorMatcher2_check_state(self) != 0) {
20232014
goto out;
20242015
}
2025-
ret = Py_BuildValue("k", (unsigned long)
2026-
ancestor_matcher2_get_total_memory(self->ancestor_matcher));
2016+
ret = Py_BuildValue(
2017+
"k", (unsigned long) ancestor_matcher2_get_total_memory(self->ancestor_matcher));
20272018
out:
20282019
return ret;
20292020
}
20302021

2031-
20322022
static PyGetSetDef AncestorMatcher2_getsetters[] = {
2033-
{"mean_traceback_size", (getter) AncestorMatcher2_get_mean_traceback_size,
2034-
NULL, "The mean size of the traceback per site."},
2035-
{"total_memory", (getter) AncestorMatcher2_get_total_memory,
2036-
NULL, "The total amount of memory used by this matcher."},
2037-
{NULL} /* Sentinel */
2023+
{ "mean_traceback_size", (getter) AncestorMatcher2_get_mean_traceback_size, NULL,
2024+
"The mean size of the traceback per site." },
2025+
{ "total_memory", (getter) AncestorMatcher2_get_total_memory, NULL,
2026+
"The total amount of memory used by this matcher." },
2027+
{ NULL } /* Sentinel */
20382028
};
20392029

20402030
static PyMethodDef AncestorMatcher2_methods[] = {
2041-
{"find_path", (PyCFunction) AncestorMatcher2_find_path,
2042-
METH_VARARGS|METH_KEYWORDS,
2043-
"Returns a best match path for the specified haplotype through the ancestors."},
2044-
{"get_traceback", (PyCFunction) AncestorMatcher2_get_traceback,
2045-
METH_VARARGS, "Returns the traceback likelihood dictionary at the specified site."},
2046-
{NULL} /* Sentinel */
2031+
{ "find_path", (PyCFunction) AncestorMatcher2_find_path,
2032+
METH_VARARGS | METH_KEYWORDS,
2033+
"Returns a best match path for the specified haplotype through the ancestors." },
2034+
{ "get_traceback", (PyCFunction) AncestorMatcher2_get_traceback, METH_VARARGS,
2035+
"Returns the traceback likelihood dictionary at the specified site." },
2036+
{ NULL } /* Sentinel */
20472037
};
20482038

2049-
20502039
static PyTypeObject AncestorMatcher2Type = {
20512040
// clang-format off
20522041
PyVarObject_HEAD_INIT(NULL, 0)

lib/ancestor_matcher.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ ancestor_matcher2_set_allelic_state(
14471447
allelic_state[0] = 0;
14481448

14491449
for (mutation = self->matcher_indexes->sites.mutations[site]; mutation != NULL;
1450-
mutation = mutation->next) {
1450+
mutation = mutation->next) {
14511451
allelic_state[mutation->node] = mutation->derived_state;
14521452
}
14531453
}
@@ -1461,7 +1461,7 @@ ancestor_matcher2_unset_allelic_state(
14611461

14621462
allelic_state[0] = NULL_NODE;
14631463
for (mutation = self->matcher_indexes->sites.mutations[site]; mutation != NULL;
1464-
mutation = mutation->next) {
1464+
mutation = mutation->next) {
14651465
allelic_state[mutation->node] = TSK_NULL;
14661466
}
14671467
}
@@ -1634,7 +1634,7 @@ ancestor_matcher2_update_site_state(ancestor_matcher2_t *self, const tsk_id_t si
16341634
ancestor_matcher2_check_state(self);
16351635
}
16361636
for (mutation = self->matcher_indexes->sites.mutations[site]; mutation != NULL;
1637-
mutation = mutation->next) {
1637+
mutation = mutation->next) {
16381638
/* Insert a new L-value for the mutation node if needed */
16391639
if (L[mutation->node] == NULL_LIKELIHOOD) {
16401640
u = mutation->node;
@@ -1803,7 +1803,7 @@ ancestor_matcher2_run_traceback(ancestor_matcher2_t *self, tsk_id_t start, tsk_i
18031803
/* The tree is ready; perform the traceback at each site in this tree */
18041804
assert(left < right);
18051805
for (; site >= 0 && left <= sites_position[site] && sites_position[site] < right;
1806-
site--) {
1806+
site--) {
18071807
if (start_pos <= sites_position[site] && sites_position[site] < end_pos) {
18081808

18091809
ancestor_matcher2_set_allelic_state(self, site, allelic_state);
@@ -2086,9 +2086,9 @@ ancestor_matcher2_find_path(ancestor_matcher2_t *self, tsk_id_t start, tsk_id_t
20862086
}
20872087
/* Reset some memory for the next call */
20882088
memset(
2089-
self->traceback + start, 0, ((size_t)(end - start)) * sizeof(*self->traceback));
2089+
self->traceback + start, 0, ((size_t) (end - start)) * sizeof(*self->traceback));
20902090
memset(self->max_likelihood_node + start, 0xff,
2091-
((size_t)(end - start)) * sizeof(*self->max_likelihood_node));
2091+
((size_t) (end - start)) * sizeof(*self->max_likelihood_node));
20922092

20932093
out:
20942094
return ret;

tsinfer/matching.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import dataclasses
2727
import logging
2828
import time as time_
29-
import dataclasses
3029

3130
import numpy as np
3231
import psutil

0 commit comments

Comments
 (0)