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
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test

on:
push:
pull_request:
schedule:
- cron: '52 4 3 * *' # 4:52a on third day of the month

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:

test:
name: Run tests
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}

strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.14"]

steps:
- uses: actions/checkout@v7

- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install package and dependencies
run: pip install .[testing]

- name: Check example script
run: |
python -m diffusion_model > model.out

- name: Check example notebook
run: |
pytest notebooks --nbmake --nbmake-timeout=3000 --nbmake-kernel=python3 -v

- name: Run unit tests
run: |
pytest -v
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@ dependencies = [
"numpy",
]

[project.optional-dependencies]
testing = [
"pytest",
"nbmake",
]

[tool.setuptools]
py-modules = ["diffusion_model"]
4 changes: 2 additions & 2 deletions tests/test_diffusion_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def test_time_step_decreases_with_diffusivity():
def test_step_like_is_array_of_float():
"""Check profile is a numpy array of floats."""
z = step_like([1.0, 2.0, 3.0])
return isinstance(z, np.ndarray) and np.issubdtype(z.dtype, np.floating)
assert isinstance(z, np.ndarray) and np.issubdtype(z.dtype, np.floating)

z = step_like([1, 2, 3])
return isinstance(z, np.ndarray) and np.issubdtype(z.dtype, np.floating)
assert isinstance(z, np.ndarray) and np.issubdtype(z.dtype, np.floating)


def test_step_like_length():
Expand Down
Loading