From 3d45be3eda4b2b600e8570b6d0d2d97da6e752b2 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 26 Aug 2026 10:37:14 -0700 Subject: [PATCH] error in schema and test machinery --- core/slim_globals.cpp | 2 +- treerec/tests/.python-version | 1 + treerec/tests/README.md | 4 ++-- treerec/tests/pip-requirements.txt | 3 +++ treerec/tests/pyproject.toml | 14 ++++++++++++++ treerec/tests/test_consistency.py | 12 +++++++----- 6 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 treerec/tests/.python-version create mode 100644 treerec/tests/pyproject.toml diff --git a/core/slim_globals.cpp b/core/slim_globals.cpp index adb3bb974..b636f744d 100644 --- a/core/slim_globals.cpp +++ b/core/slim_globals.cpp @@ -2355,7 +2355,7 @@ const std::string gSLiM_tsk_individual_metadata_schema_FORMAT_SOURCE = R"V0G0N({ "sex": { "index": 8, "type": "integer", - "binaryFormat": "i", + "binaryFormat": "h", "description": "The sex of the individual (0 for female, 1 for male, -1 for hermaphrodite)." }, "tagL0_set": { diff --git a/treerec/tests/.python-version b/treerec/tests/.python-version new file mode 100644 index 000000000..24ee5b1be --- /dev/null +++ b/treerec/tests/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/treerec/tests/README.md b/treerec/tests/README.md index e1343bfc0..ad71e4862 100644 --- a/treerec/tests/README.md +++ b/treerec/tests/README.md @@ -1,8 +1,8 @@ # Test suite for tree sequence output from SLiM ## Running the tests -Just do `python3 -m pytest` from within this directory to run the tests on the results of SLiM scripts listed in the `testRecipes/` directory. Alternatively, to run just one of the recipes do e.g. -`python3 -m pytest -k test_000_sexual_nonwf` +Just do `uv run pytest` from within this directory to run the tests on the results of SLiM scripts listed in the `testRecipes/` directory. Alternatively, to run just one of the recipes do e.g. +`uv run pytest -k test_000_sexual_nonwf` ## Recaching in GitHub Actions to get a new tskit/msprime version GitHub Actions caches its install of `tskit`, `msprime`, and other software. When a new version of such software is released, a recache needs to be forced or these tests will likely fail in CI. This cannot presently be gone in GitHub's UI; see [this GitHub issue](https://github.com/actions/cache/issues/2). So to trigger a recache, you need to increment the cache version number. It is found in `.github/workflows/tests.yml` in the line: diff --git a/treerec/tests/pip-requirements.txt b/treerec/tests/pip-requirements.txt index 4f06967ab..51e20be6c 100644 --- a/treerec/tests/pip-requirements.txt +++ b/treerec/tests/pip-requirements.txt @@ -3,3 +3,6 @@ filelock numpy pytest pytest-xdist +tskit>=0.4.1 +msprime>=1.2.0 +pyslim>=1.0.4 diff --git a/treerec/tests/pyproject.toml b/treerec/tests/pyproject.toml new file mode 100644 index 000000000..ed2fd28ab --- /dev/null +++ b/treerec/tests/pyproject.toml @@ -0,0 +1,14 @@ +[project] +name = "SLiM_python_tests" +version = "0.1.0" +requires-python = ">=3.13" +dependencies = [ + "filelock>=3.32.4", + "msprime>=1.2.0", + "numpy>=2.5.2", + "pyslim>=1.0.4", + "pytest>=9.1.1", + "pytest-xdist>=3.8.0", + "setuptools>=84.0.0", + "tskit>=0.4.1", +] diff --git a/treerec/tests/test_consistency.py b/treerec/tests/test_consistency.py index 5c5787e9e..21f5f9700 100644 --- a/treerec/tests/test_consistency.py +++ b/treerec/tests/test_consistency.py @@ -290,11 +290,12 @@ def test_chromosome_consistency(self, recipe): for tsl in result.get_ts(): for chrom_id in tsl: ts = tsl[chrom_id] - chrom_type = ts.metadata['SLiM']['this_chromosome']['type'] - chrom_index = ts.metadata['SLiM']['this_chromosome']['index'] + ts_metadata = ts.metadata + chrom_type = ts_metadata['SLiM']['this_chromosome']['type'] + chrom_index = ts_metadata['SLiM']['this_chromosome']['index'] details = self.chrom_details(chrom_type) if chrom_type in ['X', 'Y', 'Z', 'W', 'HF', 'FL', 'HM', 'ML']: - assert ts.metadata['SLiM']['separate_sexes'] + assert ts_metadata['SLiM']['separate_sexes'] for ind in ts.individuals(): if ind.flags & (pyslim.INDIVIDUAL_ALIVE | pyslim.INDIVIDUAL_REMEMBERED) > 0: sex = {0 : "F", 1 : "M", -1 : "H"}[ind.metadata['sex']] @@ -322,10 +323,11 @@ def test_chromosome_inheritance(self, recipe): for tsl in result.get_ts(): for chrom_id in tsl: ts = tsl[chrom_id] - chrom_type = ts.metadata['SLiM']['this_chromosome']['type'] + ts_metadata = ts.metadata + chrom_type = ts_metadata['SLiM']['this_chromosome']['type'] if chrom_type == "H": continue - chrom_index = ts.metadata['SLiM']['this_chromosome']['index'] + chrom_index = ts_metadata['SLiM']['this_chromosome']['index'] inheritance = self.chrom_inheritance(chrom_type) for ind in ts.individuals(): if len(ind.parents) > 0: