Skip to content

Commit e77b7be

Browse files
Initial prek+ruff setup
1 parent eb75267 commit e77b7be

79 files changed

Lines changed: 719 additions & 1044 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codecov.yml

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,61 @@
1-
codecov:
2-
require_ci_to_pass: false
1+
# ignore:
2+
# - "lib/tests/"
3+
# - "lib/dev-tools/"
4+
# - "lib/avl.c"
5+
# - "lib/subprojects/**/*"
6+
37
comment:
4-
layout: "diff, flags, files"
5-
fixes:
6-
- "tskit/::python/tskit/"
7-
flag_management:
8-
individual_flags:
9-
- name: python-tests
8+
layout: "header, diff, flags, components" # show component info in the PR comment
9+
10+
component_management:
11+
individual_components:
12+
- component_id: python_code
13+
name: Python API
1014
paths:
1115
- python/tskit/*.py
12-
statuses:
13-
- type: project
14-
target: 95%
15-
- name: python-c-tests
16+
17+
- component_id: python_c_code
18+
name: Python C interface
1619
paths:
1720
- python/_tskitmodule.c
18-
statuses:
19-
- type: project
20-
target: 85%
21-
- name: c-tests
21+
22+
- component_id: c_code
23+
name: C library
2224
paths:
23-
- c/tskit/*.c
24-
- c/tskit/*.h
25-
statuses:
26-
- type: project
27-
target: 85%
28-
- name: lwt-tests
29-
paths:
30-
- python/lwt_interface/*.c
31-
- python/lwt_interface/*.h
32-
statuses:
33-
- type: project
34-
target: 80%
25+
- c
26+
27+
#
28+
# codecov:
29+
# require_ci_to_pass: false
30+
# comment:
31+
# layout: "diff, flags, files"
32+
# fixes:
33+
# - "tskit/::python/tskit/"
34+
# flag_management:
35+
# individual_flags:
36+
# - name: python-tests
37+
# paths:
38+
# - python/tskit/*.py
39+
# statuses:
40+
# - type: project
41+
# target: 95%
42+
# - name: python-c-tests
43+
# paths:
44+
# - python/_tskitmodule.c
45+
# statuses:
46+
# - type: project
47+
# target: 85%
48+
# - name: c-tests
49+
# paths:
50+
# - c/tskit/*.c
51+
# - c/tskit/*.h
52+
# statuses:
53+
# - type: project
54+
# target: 85%
55+
# - name: lwt-tests
56+
# paths:
57+
# - python/lwt_interface/*.c
58+
# - python/lwt_interface/*.h
59+
# statuses:
60+
# - type: project
61+
# target: 80%

.github/workflows/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212

1313
jobs:
1414
Docs:
15-
uses: tskit-dev/.github/.github/workflows/docs-build-template.yml@v1
15+
uses: tskit-dev/.github/.github/workflows/docs.yml@main
1616
with:
17-
additional-setup: sudo apt-get install -y doxygen
18-
make-command: make -C python
17+
pyproject-directory: python
18+
doxygen-directory: docs/doxygen

.github/workflows/lint.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
Lint:
8+
uses: tskit-dev/.github/.github/workflows/lint.yml@main
9+
with:
10+
pyproject-directory: python

.github/workflows/tests.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ env:
1010
FORCE_COLOR: 1
1111

1212
jobs:
13-
pre-commit:
14-
name: Lint
15-
uses: tskit-dev/.github/.github/workflows/lint.yml@v5
16-
with:
17-
clang-format-version: 21.1.8
1813

1914
packaging:
2015
name: Python packaging
@@ -23,13 +18,27 @@ jobs:
2318
working-directory: python
2419
cli-test-cmd: tskit --help
2520

21+
test-c:
22+
name: C tests
23+
uses: tskit-dev/.github/.github/workflows/c-tests.yml@main
24+
with:
25+
library-directory: c
26+
secrets: inherit
27+
28+
test-python-c:
29+
name: Python-C tests
30+
uses: tskit-dev/.github/.github/workflows/python-c-tests.yml@main
31+
with:
32+
pyproject-directory: python
33+
secrets: inherit
34+
2635
test:
2736
name: Python
2837
runs-on: ${{ matrix.os }}
2938
strategy:
3039
fail-fast: false
3140
matrix:
32-
python: [ 3.11, 3.14 ]
41+
python: [ 3.11, 3.13 ]
3342
os: [ macos-latest, ubuntu-24.04, windows-latest ]
3443
defaults:
3544
run:
@@ -97,6 +106,7 @@ jobs:
97106
flags: python-tests-no-jit
98107
name: codecov-umbrella
99108
verbose: true
109+
100110
- name: Run tests
101111
working-directory: python
102112
run: |
@@ -113,7 +123,7 @@ jobs:
113123
working-directory: python
114124
fail_ci_if_error: false
115125
flags: python-tests
116-
name: codecov-umbrella
126+
gcov_args: --preserve-paths
117127
verbose: true
118128

119129
msys2:

c/examples/error_handling.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ main(int argc, char **argv)
2121
}
2222
printf("Loaded tree sequence with %lld nodes and %lld edges from %s\n",
2323
(long long) tsk_treeseq_get_num_nodes(&ts),
24-
(long long) tsk_treeseq_get_num_edges(&ts),
25-
argv[1]);
24+
(long long) tsk_treeseq_get_num_edges(&ts), argv[1]);
2625
tsk_treeseq_free(&ts);
2726

2827
return EXIT_SUCCESS;

c/examples/haploid_wright_fisher.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
}
1212

1313
void
14-
simulate(
15-
tsk_table_collection_t *tables, int N, int T, int simplify_interval)
14+
simulate(tsk_table_collection_t *tables, int N, int T, int simplify_interval)
1615
{
1716
tsk_id_t *buffer, *parents, *children, child, left_parent, right_parent;
1817
double breakpoint;
@@ -44,10 +43,10 @@ simulate(
4443
* research code and proper random number generator
4544
* libraries should be preferred.
4645
*/
47-
left_parent = parents[(size_t)((rand()/(1.+RAND_MAX))*N)];
48-
right_parent = parents[(size_t)((rand()/(1.+RAND_MAX))*N)];
46+
left_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
47+
right_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
4948
do {
50-
breakpoint = rand()/(1.+RAND_MAX);
49+
breakpoint = rand() / (1. + RAND_MAX);
5150
} while (breakpoint == 0); /* tiny proba of breakpoint being 0 */
5251
ret = tsk_edge_table_add_row(
5352
&tables->edges, 0, breakpoint, left_parent, child, NULL, 0);
@@ -58,18 +57,15 @@ simulate(
5857
children[j] = child;
5958
}
6059
if (t % simplify_interval == 0) {
61-
printf("Simplify at generation %lld: (%lld nodes %lld edges)",
62-
(long long) t,
63-
(long long) tables->nodes.num_rows,
64-
(long long) tables->edges.num_rows);
60+
printf("Simplify at generation %lld: (%lld nodes %lld edges)", (long long) t,
61+
(long long) tables->nodes.num_rows, (long long) tables->edges.num_rows);
6562
/* Note: Edges must be sorted for simplify to work, and we use a brute force
6663
* approach of sorting each time here for simplicity. This is inefficient. */
6764
ret = tsk_table_collection_sort(tables, NULL, 0);
6865
check_tsk_error(ret);
6966
ret = tsk_table_collection_simplify(tables, children, N, 0, NULL);
7067
check_tsk_error(ret);
71-
printf(" -> (%lld nodes %lld edges)\n",
72-
(long long) tables->nodes.num_rows,
68+
printf(" -> (%lld nodes %lld edges)\n", (long long) tables->nodes.num_rows,
7369
(long long) tables->edges.num_rows);
7470
for (j = 0; j < N; j++) {
7571
children[j] = j;
@@ -90,7 +86,7 @@ main(int argc, char **argv)
9086
}
9187
ret = tsk_table_collection_init(&tables, 0);
9288
check_tsk_error(ret);
93-
srand((unsigned)atoi(argv[5]));
89+
srand((unsigned) atoi(argv[5]));
9490
simulate(&tables, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
9591

9692
/* Sort and index so that the result can be opened as a tree sequence */

c/examples/multichrom_wright_fisher.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ simulate(
212212
* research code and proper random number generator
213213
* libraries should be preferred.
214214
*/
215-
left_parent = parents[(size_t)((rand() / (1. + RAND_MAX)) * N)];
216-
right_parent = parents[(size_t)((rand() / (1. + RAND_MAX)) * N)];
215+
left_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
216+
right_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
217217
left_is_first = rand() < 0.5;
218218
chunk_left = 0.0;
219219
for (k = 0; k < num_chroms; k++) {

c/examples/multichrom_wright_fisher_singlethreaded.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ simulate(
4646
* research code and proper random number generator
4747
* libraries should be preferred.
4848
*/
49-
left_parent = parents[(size_t)((rand() / (1. + RAND_MAX)) * N)];
50-
right_parent = parents[(size_t)((rand() / (1. + RAND_MAX)) * N)];
49+
left_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
50+
right_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
5151
left_is_first = rand() < 0.5;
5252
chunk_left = 0.0;
5353
for (k = 0; k < num_chroms; k++) {
@@ -68,18 +68,15 @@ simulate(
6868
children[j] = child;
6969
}
7070
if (t % simplify_interval == 0) {
71-
printf("Simplify at generation %lld: (%lld nodes %lld edges)",
72-
(long long) t,
73-
(long long) tables->nodes.num_rows,
74-
(long long) tables->edges.num_rows);
71+
printf("Simplify at generation %lld: (%lld nodes %lld edges)", (long long) t,
72+
(long long) tables->nodes.num_rows, (long long) tables->edges.num_rows);
7573
/* Note: Edges must be sorted for simplify to work, and we use a brute force
7674
* approach of sorting each time here for simplicity. This is inefficient. */
7775
ret = tsk_table_collection_sort(tables, NULL, 0);
7876
check_tsk_error(ret);
7977
ret = tsk_table_collection_simplify(tables, children, N, 0, NULL);
8078
check_tsk_error(ret);
81-
printf(" -> (%lld nodes %lld edges)\n",
82-
(long long) tables->nodes.num_rows,
79+
printf(" -> (%lld nodes %lld edges)\n", (long long) tables->nodes.num_rows,
8380
(long long) tables->edges.num_rows);
8481
for (j = 0; j < N; j++) {
8582
children[j] = j;
@@ -104,7 +101,7 @@ main(int argc, char **argv)
104101
}
105102
ret = tsk_table_collection_init(&tables, 0);
106103
check_tsk_error(ret);
107-
srand((unsigned)atoi(argv[5]));
104+
srand((unsigned) atoi(argv[5]));
108105
simulate(&tables, atoi(argv[6]), atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
109106

110107
/* Sort and index so that the result can be opened as a tree sequence */

c/examples/tree_iteration.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ main(int argc, char **argv)
2626

2727
printf("Iterate forwards\n");
2828
for (ret = tsk_tree_first(&tree); ret == TSK_TREE_OK; ret = tsk_tree_next(&tree)) {
29-
printf("\ttree %lld has %lld roots\n",
30-
(long long) tree.index,
29+
printf("\ttree %lld has %lld roots\n", (long long) tree.index,
3130
(long long) tsk_tree_get_num_roots(&tree));
3231
}
3332
check_tsk_error(ret);
3433

3534
printf("Iterate backwards\n");
3635
for (ret = tsk_tree_last(&tree); ret == TSK_TREE_OK; ret = tsk_tree_prev(&tree)) {
37-
printf("\ttree %lld has %lld roots\n",
38-
(long long) tree.index,
36+
printf("\ttree %lld has %lld roots\n", (long long) tree.index,
3937
(long long) tsk_tree_get_num_roots(&tree));
4038
}
4139
check_tsk_error(ret);

docs/Makefile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
2-
# Need to set PYTHONPATH so that we pick up the local tskit
3-
PYPATH=$(shell pwd)/../python/
4-
TSK_VERSION:=$(shell PYTHONPATH=${PYPATH} \
5-
python -c 'import tskit; print(tskit.__version__.split("+")[0])')
6-
71
BUILDDIR = _build
82
DOXYGEN_XML=doxygen/xml
93

@@ -13,13 +7,7 @@ ${DOXYGEN_XML}: ../c/tskit/*.h
137
cd doxygen && doxygen
148

159
dev:
16-
PYTHONPATH=${PYPATH} ./build.sh
17-
18-
dist:
19-
@echo Building distribution for tskit version ${TSK_VERSION}
20-
cd doxygen && doxygen
21-
sed -i -e s/__TSKIT_VERSION__/${TSK_VERSION}/g _config.yml
22-
PYTHONPATH=${PYPATH} ./build.sh
10+
uv --project=../python run jupyter-book build -Wn --keep-going .
2311

2412
clean:
2513
rm -fR $(BUILDDIR) $(DOXYGEN_XML)

0 commit comments

Comments
 (0)