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
2 changes: 1 addition & 1 deletion core/slim_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions treerec/tests/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
4 changes: 2 additions & 2 deletions treerec/tests/README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
3 changes: 3 additions & 0 deletions treerec/tests/pip-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ filelock
numpy
pytest
pytest-xdist
tskit>=0.4.1
msprime>=1.2.0
pyslim>=1.0.4
14 changes: 14 additions & 0 deletions treerec/tests/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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",
]
12 changes: 7 additions & 5 deletions treerec/tests/test_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']]
Expand Down Expand Up @@ -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:
Expand Down
Loading