Skip to content

Commit 46d7137

Browse files
committed
Add CI test
1 parent c8e161b commit 46d7137

4 files changed

Lines changed: 65 additions & 8 deletions

File tree

.github/workflows/tests.yml

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,60 @@ jobs:
126126
python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 --durations=20 tests
127127
fi
128128
129-
- name: Build and run with numpy 1.x
129+
- name: Upload coverage to Codecov
130+
uses: codecov/codecov-action@v5.4.0
131+
with:
132+
token: ${{ secrets.CODECOV_TOKEN }}
133+
working-directory: python
134+
fail_ci_if_error: false
135+
flags: python-tests
136+
name: codecov-umbrella
137+
verbose: true
138+
139+
test-numpy1:
140+
name: Numpy 1.x
141+
runs-on: ubuntu-24.04
142+
defaults:
143+
run:
144+
shell: bash
145+
steps:
146+
- name: Cancel Previous Runs
147+
uses: styfle/cancel-workflow-action@0.12.1
148+
with:
149+
access_token: ${{ github.token }}
150+
151+
- name: Checkout
152+
uses: actions/checkout@v4.2.2
153+
154+
- name: Setup Python
155+
uses: actions/setup-python@v5.4.0
156+
with:
157+
python-version: '3.12'
158+
159+
- name: Install dependencies
130160
working-directory: python
131161
run: |
132-
source ~/.profile
133-
conda activate anaconda-client-env
134-
conda install --yes "numpy<2"
135-
python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 tests/test_lowlevel.py
162+
pip install -r requirements/CI-complete/requirements.txt
163+
pip install "numpy<2"
136164
165+
- name: Build module
166+
working-directory: python
167+
run: |
168+
python setup.py build_ext --inplace
169+
170+
- name: Run tests with numpy 1.x
171+
working-directory: python
172+
run: |
173+
python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 tests/test_lowlevel.py tests/test_highlevel.py
137174
138175
- name: Upload coverage to Codecov
139176
uses: codecov/codecov-action@v5.4.0
140177
with:
141178
token: ${{ secrets.CODECOV_TOKEN }}
142179
working-directory: python
143180
fail_ci_if_error: false
144-
flags: python-tests
145-
name: codecov-umbrella
181+
flags: python-tests-numpy1
182+
name: codecov-numpy1
146183
verbose: true
147184

148185
msys2:

python/CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
- Add ``TreeSequence.mutations_edge`` which returns the edge ID for each mutation's
2020
edge. (:user:`benjeffery`, :pr:`3226`, :issue:`3189`)
2121

22+
- Add ``TreeSequence.sites_ancestral_state`` and ``TreeSequence.mutations_derived_state`` properties
23+
to return the ancestral state of sites and derived state of mutations as NumPy arrays of
24+
the new numpy 2.0 StringDType.
25+
(:user:`benjeffery`, :pr:`3228`, :issue:`2632`)
26+
2227
**Bugfixes**
2328

2429
- Fix bug in ``TreeSequence.pair_coalescence_counts`` when ``span_normalise=True``

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ keywords = [
4343
requires-python = ">=3.9"
4444
dependencies = [
4545
"jsonschema>=3.0.0",
46-
"numpy>2",
46+
"numpy>=2",
4747
]
4848

4949
[project.urls]

python/tests/test_highlevel.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5322,6 +5322,7 @@ def test_mixed_sample_status(self):
53225322

53235323

53245324
class TestRaggedArrays:
5325+
@pytest.mark.skipif(not _tskit.HAS_NUMPY_2, reason="Requires NumPy 2.0 or higher")
53255326
@pytest.mark.parametrize("num_rows", [0, 1, 100])
53265327
@pytest.mark.parametrize("column", ["ancestral_state", "derived_state"])
53275328
def test_site_ancestral_state(self, num_rows, column):
@@ -5367,6 +5368,20 @@ def test_site_ancestral_state(self, num_rows, column):
53675368
):
53685369
assert state == getattr(row, column)
53695370

5371+
@pytest.mark.skipif(_tskit.HAS_NUMPY_2, reason="Test only on Numpy 1.X")
5372+
@pytest.mark.parametrize(
5373+
"column", ["sites_ancestral_state", "mutations_derived_state"]
5374+
)
5375+
def test_ragged_array_not_supported(self, column):
5376+
tables = tskit.TableCollection(sequence_length=100)
5377+
ts = tables.tree_sequence()
5378+
5379+
with pytest.raises(
5380+
RuntimeError,
5381+
match="requires numpy 2.0",
5382+
):
5383+
getattr(ts, column)
5384+
53705385

53715386
class TestSampleNodesByPloidy:
53725387
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)