Skip to content

Commit 9bf5d5c

Browse files
committed
Add SymPy integration and Devito wave solver infrastructure
Phase 0 and 0.5 of the Devito book refactoring: - src/symbols.py: Common SymPy symbols for variables, parameters - src/operators.py: Finite difference operators with Taylor series analysis - src/display.py: LaTeX rendering utilities for Quarto documents - src/verification.py: Tools for verifying mathematical derivations - src/plotting.py: Reproducible plotting with fixed seed (42) - src/wave/wave1D_devito.py: 1D wave equation solver using Devito DSL Testing infrastructure: - tests/test_operators.py: 37 tests for FD operators - tests/test_derivations.py: 22 tests for heat, wave, advection equations - tests/test_wave_devito.py: 13 tests for Devito wave solver - tests/conftest.py: Shared pytest fixtures CI/CD: - .github/workflows/ci.yml: GitHub Actions workflow - codecov.yml: Coverage reporting configuration - pytest.ini: Pytest configuration Dependencies: - Add optional devito and devito-petsc dependencies from GitHub
1 parent ca1a775 commit 9bf5d5c

23 files changed

Lines changed: 7116 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, devito]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
# Run tests for mathematical derivations and operators with coverage
11+
test-derivations:
12+
name: Test Mathematical Derivations
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.11'
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install pytest pytest-cov numpy sympy matplotlib
28+
29+
- name: Run tests with coverage
30+
run: |
31+
pytest tests/test_operators.py tests/test_derivations.py -v --cov=src --cov-report=xml --cov-report=term-missing
32+
33+
- name: Upload coverage to Codecov
34+
uses: codecov/codecov-action@v4
35+
with:
36+
token: ${{ secrets.CODECOV_TOKEN }}
37+
files: ./coverage.xml
38+
flags: derivations
39+
name: derivations-coverage
40+
fail_ci_if_error: false
41+
42+
# Run explicit Devito solver tests with coverage
43+
test-devito-explicit:
44+
name: Test Devito Explicit Solvers
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- name: Checkout repository
49+
uses: actions/checkout@v4
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@v5
53+
with:
54+
python-version: '3.11'
55+
56+
- name: Install dependencies
57+
run: |
58+
python -m pip install --upgrade pip
59+
pip install pytest pytest-cov numpy sympy matplotlib
60+
pip install devito
61+
62+
- name: Run Devito tests with coverage
63+
run: |
64+
pytest tests/ -v -m "devito" --cov=src --cov-report=xml --cov-report=term-missing --tb=short
65+
continue-on-error: true # Allow to continue even if Devito tests fail initially
66+
67+
- name: Upload coverage to Codecov
68+
uses: codecov/codecov-action@v4
69+
with:
70+
token: ${{ secrets.CODECOV_TOKEN }}
71+
files: ./coverage.xml
72+
flags: devito
73+
name: devito-coverage
74+
fail_ci_if_error: false
75+
76+
# Lint and style checks
77+
lint:
78+
name: Lint and Style
79+
runs-on: ubuntu-latest
80+
81+
steps:
82+
- name: Checkout repository
83+
uses: actions/checkout@v4
84+
85+
- name: Set up Python
86+
uses: actions/setup-python@v5
87+
with:
88+
python-version: '3.11'
89+
90+
- name: Install linting tools
91+
run: |
92+
python -m pip install --upgrade pip
93+
pip install ruff isort
94+
95+
- name: Run ruff check
96+
run: |
97+
ruff check src/ tests/ --select=E,W,F --ignore=F403,F405,E501
98+
99+
- name: Check import ordering
100+
run: |
101+
isort --check-only src/ tests/ --skip __init__.py
102+
continue-on-error: true
103+
104+
# Build Quarto book
105+
build-book:
106+
name: Build Quarto Book
107+
runs-on: ubuntu-latest
108+
109+
steps:
110+
- name: Checkout repository
111+
uses: actions/checkout@v4
112+
113+
- name: Set up Python
114+
uses: actions/setup-python@v5
115+
with:
116+
python-version: '3.11'
117+
118+
- name: Install Python dependencies
119+
run: |
120+
python -m pip install --upgrade pip
121+
pip install numpy sympy matplotlib jupyter
122+
123+
- name: Set up Quarto
124+
uses: quarto-dev/quarto-actions/setup@v2
125+
with:
126+
version: '1.4.554'
127+
128+
- name: Install TinyTeX
129+
run: |
130+
quarto install tinytex
131+
132+
- name: Render book
133+
run: |
134+
quarto render --to pdf
135+
continue-on-error: true # Book may not build initially
136+
137+
- name: Upload book artifact
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: book-pdf
141+
path: _book/*.pdf
142+
if: success()

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,10 @@ title_test.*
7171
/.quarto/
7272
/_book/
7373
**/*.quarto_ipynb
74+
75+
# Coverage
76+
.coverage
77+
coverage.xml
78+
htmlcov/
79+
.pytest_cache/
80+
devito_repo/

.markdownlintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ _book/
88
# Virtual environments
99
venv/
1010
.venv/
11+
12+
# External repositories
13+
devito_repo/
14+
15+
# Planning documents (not code)
16+
devito-plan.md

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ repos:
4242
- id: markdownlint-cli2
4343
name: "Check markdown files"
4444
stages: [pre-commit]
45+
exclude: '^(devito_repo/|venv/|devito-plan\.md)'
4546
#
4647
# These stages modify the files applying fixes where possible
4748
# Since this may be undesirable they will not run automatically
@@ -79,3 +80,4 @@ repos:
7980
name: "Fix markdown files"
8081
args: [--fix]
8182
stages: [manual]
83+
exclude: '^(devito_repo/|venv/|devito-plan\.md)'

codecov.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Codecov configuration
2+
# https://docs.codecov.com/docs/codecov-yaml
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "60...100"
8+
9+
status:
10+
project:
11+
default:
12+
target: auto
13+
threshold: 5%
14+
informational: true
15+
patch:
16+
default:
17+
target: auto
18+
threshold: 5%
19+
informational: true
20+
21+
parsers:
22+
gcov:
23+
branch_detection:
24+
conditional: yes
25+
loop: yes
26+
method: no
27+
macro: no
28+
29+
comment:
30+
layout: "reach,diff,flags,files"
31+
behavior: default
32+
require_changes: false
33+
34+
flags:
35+
derivations:
36+
paths:
37+
- src/symbols.py
38+
- src/operators.py
39+
- src/verification.py
40+
- src/display.py
41+
carryforward: true
42+
43+
devito:
44+
paths:
45+
- src/wave/
46+
- src/diffu/
47+
- src/advec/
48+
- src/vib/
49+
carryforward: true
50+
51+
ignore:
52+
- "tests/**/*"
53+
- "**/__init__.py"
54+
- "src/legacy/**/*"

0 commit comments

Comments
 (0)