Skip to content

Commit 9a65a4d

Browse files
authored
Merge pull request #669 from petrelharp/fix_666
error in schema and test machinery
2 parents fb295de + 3d45be3 commit 9a65a4d

6 files changed

Lines changed: 28 additions & 8 deletions

File tree

core/slim_globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ const std::string gSLiM_tsk_individual_metadata_schema_FORMAT_SOURCE = R"V0G0N({
23552355
"sex": {
23562356
"index": 8,
23572357
"type": "integer",
2358-
"binaryFormat": "i",
2358+
"binaryFormat": "h",
23592359
"description": "The sex of the individual (0 for female, 1 for male, -1 for hermaphrodite)."
23602360
},
23612361
"tagL0_set": {

treerec/tests/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

treerec/tests/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Test suite for tree sequence output from SLiM
22

33
## Running the tests
4-
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.
5-
`python3 -m pytest -k test_000_sexual_nonwf`
4+
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.
5+
`uv run pytest -k test_000_sexual_nonwf`
66

77
## Recaching in GitHub Actions to get a new tskit/msprime version
88
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:

treerec/tests/pip-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ filelock
33
numpy
44
pytest
55
pytest-xdist
6+
tskit>=0.4.1
7+
msprime>=1.2.0
8+
pyslim>=1.0.4

treerec/tests/pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[project]
2+
name = "SLiM_python_tests"
3+
version = "0.1.0"
4+
requires-python = ">=3.13"
5+
dependencies = [
6+
"filelock>=3.32.4",
7+
"msprime>=1.2.0",
8+
"numpy>=2.5.2",
9+
"pyslim>=1.0.4",
10+
"pytest>=9.1.1",
11+
"pytest-xdist>=3.8.0",
12+
"setuptools>=84.0.0",
13+
"tskit>=0.4.1",
14+
]

treerec/tests/test_consistency.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,12 @@ def test_chromosome_consistency(self, recipe):
290290
for tsl in result.get_ts():
291291
for chrom_id in tsl:
292292
ts = tsl[chrom_id]
293-
chrom_type = ts.metadata['SLiM']['this_chromosome']['type']
294-
chrom_index = ts.metadata['SLiM']['this_chromosome']['index']
293+
ts_metadata = ts.metadata
294+
chrom_type = ts_metadata['SLiM']['this_chromosome']['type']
295+
chrom_index = ts_metadata['SLiM']['this_chromosome']['index']
295296
details = self.chrom_details(chrom_type)
296297
if chrom_type in ['X', 'Y', 'Z', 'W', 'HF', 'FL', 'HM', 'ML']:
297-
assert ts.metadata['SLiM']['separate_sexes']
298+
assert ts_metadata['SLiM']['separate_sexes']
298299
for ind in ts.individuals():
299300
if ind.flags & (pyslim.INDIVIDUAL_ALIVE | pyslim.INDIVIDUAL_REMEMBERED) > 0:
300301
sex = {0 : "F", 1 : "M", -1 : "H"}[ind.metadata['sex']]
@@ -322,10 +323,11 @@ def test_chromosome_inheritance(self, recipe):
322323
for tsl in result.get_ts():
323324
for chrom_id in tsl:
324325
ts = tsl[chrom_id]
325-
chrom_type = ts.metadata['SLiM']['this_chromosome']['type']
326+
ts_metadata = ts.metadata
327+
chrom_type = ts_metadata['SLiM']['this_chromosome']['type']
326328
if chrom_type == "H":
327329
continue
328-
chrom_index = ts.metadata['SLiM']['this_chromosome']['index']
330+
chrom_index = ts_metadata['SLiM']['this_chromosome']['index']
329331
inheritance = self.chrom_inheritance(chrom_type)
330332
for ind in ts.individuals():
331333
if len(ind.parents) > 0:

0 commit comments

Comments
 (0)