Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 55 additions & 28 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,61 @@
codecov:
require_ci_to_pass: false
# ignore:
# - "lib/tests/"
# - "lib/dev-tools/"
# - "lib/avl.c"
# - "lib/subprojects/**/*"

comment:
layout: "diff, flags, files"
fixes:
- "tskit/::python/tskit/"
flag_management:
individual_flags:
- name: python-tests
layout: "header, diff, flags, components" # show component info in the PR comment

component_management:
individual_components:
- component_id: python_code
name: Python API
paths:
- python/tskit/*.py
statuses:
- type: project
target: 95%
- name: python-c-tests

- component_id: python_c_code
name: Python C interface
paths:
- python/_tskitmodule.c
statuses:
- type: project
target: 85%
- name: c-tests

- component_id: c_code
name: C library
paths:
- c/tskit/*.c
- c/tskit/*.h
statuses:
- type: project
target: 85%
- name: lwt-tests
paths:
- python/lwt_interface/*.c
- python/lwt_interface/*.h
statuses:
- type: project
target: 80%
- c

#
# codecov:
# require_ci_to_pass: false
# comment:
# layout: "diff, flags, files"
# fixes:
# - "tskit/::python/tskit/"
# flag_management:
# individual_flags:
# - name: python-tests
# paths:
# - python/tskit/*.py
# statuses:
# - type: project
# target: 95%
# - name: python-c-tests
# paths:
# - python/_tskitmodule.c
# statuses:
# - type: project
# target: 85%
# - name: c-tests
# paths:
# - c/tskit/*.c
# - c/tskit/*.h
# statuses:
# - type: project
# target: 85%
# - name: lwt-tests
# paths:
# - python/lwt_interface/*.c
# - python/lwt_interface/*.h
# statuses:
# - type: project
# target: 80%
1 change: 0 additions & 1 deletion .github/workflows/docker/shared.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ PYTHON_VERSIONS=(
cp313-cp313
cp312-cp312
cp311-cp311
cp310-cp310
)
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:

jobs:
Docs:
uses: tskit-dev/.github/.github/workflows/docs-build-template.yml@v1
uses: tskit-dev/.github/.github/workflows/docs.yml@main
with:
additional-setup: sudo apt-get install -y doxygen
make-command: make -C python
pyproject-directory: python
doxygen-directory: docs/doxygen
10 changes: 10 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Lint

on:
pull_request:

jobs:
Lint:
uses: tskit-dev/.github/.github/workflows/lint.yml@main
with:
pyproject-directory: python
91 changes: 23 additions & 68 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ env:
FORCE_COLOR: 1

jobs:
pre-commit:
name: Lint
uses: tskit-dev/.github/.github/workflows/lint.yml@v5
with:
clang-format-version: 21.1.8

packaging:
name: Python packaging
Expand All @@ -23,13 +18,27 @@ jobs:
working-directory: python
cli-test-cmd: tskit --help

test-c:
name: C tests
uses: tskit-dev/.github/.github/workflows/c-tests.yml@main
with:
library-directory: c
secrets: inherit

test-python-c:
name: Python-C tests
uses: tskit-dev/.github/.github/workflows/python-c-tests.yml@main
with:
pyproject-directory: python
secrets: inherit

test:
name: Python
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python: [ "3.10", 3.14 ]
python: [ 3.11, 3.13 ]
os: [ macos-latest, ubuntu-24.04, windows-latest ]
defaults:
run:
Expand Down Expand Up @@ -67,27 +76,26 @@ jobs:
- name: Install dependencies
working-directory: python
run: |
uv venv
uv pip install -r pyproject.toml --extra test
uv sync --locked --group test
# Remove tskit installed as a dep of msprime
uv pip uninstall tskit

- name: Build module
working-directory: python
run: |
uv run --no-sync python setup.py build_ext --inplace
uv run python setup.py build_ext --inplace

- name: Minidom test
working-directory: python
# Importing either IPython or pytest causes import of xml.dom.minidom
# So to actually test that tskit imports it, we need a minimal test
run: |
uv run --no-sync python -c "import tskit;tskit.Tree.generate_star(5).tree_sequence.draw_svg(path='test.svg')"
uv run python -c "import tskit;tskit.Tree.generate_star(5).tree_sequence.draw_svg(path='test.svg')"

- name: Run JIT code coverage
working-directory: python
run: |
NUMBA_DISABLE_JIT=1 uv run --no-sync python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 tests/test_jit.py
NUMBA_DISABLE_JIT=1 uv run pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 tests/test_jit.py

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5.5.2
Expand All @@ -98,13 +106,14 @@ jobs:
flags: python-tests-no-jit
name: codecov-umbrella
verbose: true

- name: Run tests
working-directory: python
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
uv run --no-sync python -m pytest -x --skip-slow --cov=tskit --cov-report=xml --cov-branch -n2 --durations=20 tests
uv run pytest -x --skip-slow --cov=tskit --cov-report=xml --cov-branch -n2 --durations=20 tests
else
uv run --no-sync python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 --durations=20 tests
uv run pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 --durations=20 tests
fi

- name: Upload coverage to Codecov
Expand All @@ -114,61 +123,7 @@ jobs:
working-directory: python
fail_ci_if_error: false
flags: python-tests
name: codecov-umbrella
verbose: true


test-numpy1:
name: Numpy 1.x
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.0
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v6.0.2

- name: Setup Python
uses: actions/setup-python@v6.1.0
with:
python-version: '3.12'

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.8.15"

- name: Install dependencies
working-directory: python
run: |
uv venv
uv pip install -r pyproject.toml --extra test
uv pip uninstall tskit
uv pip install "numpy<2"

- name: Build module
working-directory: python
run: |
uv run --no-sync python setup.py build_ext --inplace

- name: Run tests with numpy 1.x
working-directory: python
run: |
uv run --no-sync python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 tests/test_lowlevel.py tests/test_highlevel.py

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
working-directory: python
fail_ci_if_error: false
flags: python-tests-numpy1
name: codecov-numpy1
gcov_args: --preserve-paths
verbose: true

msys2:
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.10", 3.11, 3.12, 3.13, 3.14]
python: [3.11, 3.12, 3.13, 3.14]
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.10", 3.11, 3.12, 3.13, 3.14]
python: [3.11, 3.12, 3.13, 3.14]
wordsize: [64]
steps:
- name: Checkout
Expand Down Expand Up @@ -91,10 +91,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v6.0.2

- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v6.1.0
with:
python-version: "3.10"
python-version: 3.11

- name: Build sdist
shell: bash
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.10", 3.11, 3.12, 3.13, 3.14]
python: [3.11, 3.12, 3.13, 3.14]
runner: [macos-15, macos-15-intel]
include:
- runner: macos-15
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.10", 3.11, 3.12, 3.13, 3.14]
python: [3.11, 3.12, 3.13, 3.14]
wordsize: [64]
steps:
- name: Download wheels
Expand All @@ -188,10 +188,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.10", 3.11, 3.12, 3.13, 3.14]
python: [3.11, 3.12, 3.13, 3.14]
include:
- python: "3.10"
wheel: cp310
- python: 3.11
wheel: cp311
- python: 3.12
Expand Down
3 changes: 1 addition & 2 deletions c/examples/error_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ main(int argc, char **argv)
}
printf("Loaded tree sequence with %lld nodes and %lld edges from %s\n",
(long long) tsk_treeseq_get_num_nodes(&ts),
(long long) tsk_treeseq_get_num_edges(&ts),
argv[1]);
(long long) tsk_treeseq_get_num_edges(&ts), argv[1]);
tsk_treeseq_free(&ts);

return EXIT_SUCCESS;
Expand Down
20 changes: 8 additions & 12 deletions c/examples/haploid_wright_fisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
}

void
simulate(
tsk_table_collection_t *tables, int N, int T, int simplify_interval)
simulate(tsk_table_collection_t *tables, int N, int T, int simplify_interval)
{
tsk_id_t *buffer, *parents, *children, child, left_parent, right_parent;
double breakpoint;
Expand Down Expand Up @@ -44,10 +43,10 @@ simulate(
* research code and proper random number generator
* libraries should be preferred.
*/
left_parent = parents[(size_t)((rand()/(1.+RAND_MAX))*N)];
right_parent = parents[(size_t)((rand()/(1.+RAND_MAX))*N)];
left_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
right_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
do {
breakpoint = rand()/(1.+RAND_MAX);
breakpoint = rand() / (1. + RAND_MAX);
} while (breakpoint == 0); /* tiny proba of breakpoint being 0 */
ret = tsk_edge_table_add_row(
&tables->edges, 0, breakpoint, left_parent, child, NULL, 0);
Expand All @@ -58,18 +57,15 @@ simulate(
children[j] = child;
}
if (t % simplify_interval == 0) {
printf("Simplify at generation %lld: (%lld nodes %lld edges)",
(long long) t,
(long long) tables->nodes.num_rows,
(long long) tables->edges.num_rows);
printf("Simplify at generation %lld: (%lld nodes %lld edges)", (long long) t,
(long long) tables->nodes.num_rows, (long long) tables->edges.num_rows);
/* Note: Edges must be sorted for simplify to work, and we use a brute force
* approach of sorting each time here for simplicity. This is inefficient. */
ret = tsk_table_collection_sort(tables, NULL, 0);
check_tsk_error(ret);
ret = tsk_table_collection_simplify(tables, children, N, 0, NULL);
check_tsk_error(ret);
printf(" -> (%lld nodes %lld edges)\n",
(long long) tables->nodes.num_rows,
printf(" -> (%lld nodes %lld edges)\n", (long long) tables->nodes.num_rows,
(long long) tables->edges.num_rows);
for (j = 0; j < N; j++) {
children[j] = j;
Expand All @@ -90,7 +86,7 @@ main(int argc, char **argv)
}
ret = tsk_table_collection_init(&tables, 0);
check_tsk_error(ret);
srand((unsigned)atoi(argv[5]));
srand((unsigned) atoi(argv[5]));
simulate(&tables, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));

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