Skip to content

Commit 2ffb14b

Browse files
committed
Restructure files
1 parent bc37515 commit 2ffb14b

19 files changed

+722
-330
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
data/*
33
code/results/*
44
code/figures/*
5+
_build
56

67

78
### Python ###

.flake8

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/build_docs.yml

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
1-
name: Github Pages
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
23

34
on:
5+
# Runs on pushes targeting the default branch
46
push:
57
branches:
6-
- main
8+
- "**"
9+
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14+
permissions:
15+
contents: read
16+
pages: write
17+
id-token: write
18+
19+
# Allow one concurrent deployment
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: true
23+
724
jobs:
8-
deploy:
25+
build:
926
runs-on: ubuntu-22.04
1027
env:
1128
# Directory that will be published on github pages
1229
PUBLISH_DIR: ./docs/_build/html
1330

1431
steps:
15-
- uses: actions/checkout@v3
32+
- uses: actions/checkout@v4
1633

1734
- name: Setup Python
1835
uses: actions/setup-python@v4
@@ -23,19 +40,31 @@ jobs:
2340
run: python3 -m pip install -r requirements-docs.txt
2441

2542
- name: Build docs
26-
run: jupyter book build docs
43+
run: jupyter book build .
2744

28-
- name: Copy requirements.txt into gh-pages
29-
run: cp requirements.txt ${PUBLISH_DIR}/
45+
- name: Upload artifact
46+
uses: actions/upload-pages-artifact@v2
47+
with:
48+
path: ${{ env.PUBLISH_DIR }}
3049

31-
- name: Copy code and data into gh-pages
32-
run: |
33-
cp -r code ${PUBLISH_DIR}/
34-
cp -r data ${PUBLISH_DIR}/
35-
cp runtime.txt ${PUBLISH_DIR}/
50+
# Single deploy job since we're just deploying
51+
deploy:
52+
if: github.ref == 'refs/heads/main'
53+
needs: build
54+
environment:
55+
name: github-pages
56+
url: ${{ steps.deployment.outputs.page_url }}
3657

37-
- name: Deploy
38-
uses: peaceiris/actions-gh-pages@v3
39-
with:
40-
github_token: ${{ secrets.GITHUB_TOKEN }}
41-
publish_dir: ${{ env.PUBLISH_DIR }}
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
64+
- name: Setup Pages
65+
uses: actions/configure-pages@v3
66+
67+
68+
- name: Deploy to GitHub Pages
69+
id: deployment
70+
uses: actions/deploy-pages@v2

.github/workflows/docker-image.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@ jobs:
2525

2626
steps:
2727
- name: Checkout repository
28-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
2929

3030
- name: Set up QEMU
31-
uses: docker/setup-qemu-action@v2
31+
uses: docker/setup-qemu-action@v3
3232

3333
- name: Set up Docker Buildx
34-
uses: docker/setup-buildx-action@v2
34+
uses: docker/setup-buildx-action@v3
3535

3636
- name: Log in to the Container registry
37-
uses: docker/login-action@v2
37+
uses: docker/login-action@v3
3838
with:
3939
registry: ${{ env.REGISTRY }}
4040
username: ${{ github.actor }}
4141
password: ${{ secrets.GITHUB_TOKEN }}
4242

4343
- name: Extract metadata (tags, labels) for Docker
4444
id: meta
45-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
45+
uses: docker/metadata-action@v5
4646
with:
4747
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4848

4949
- name: Build and push Docker image
50-
uses: docker/build-push-action@v3
50+
uses: docker/build-push-action@v5
5151
with:
5252
context: .
5353
push: true

.github/workflows/pre-commit.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Pre-commit
2+
3+
on: [push]
4+
5+
6+
jobs:
7+
check-code:
8+
runs-on: ubuntu-22.04
9+
steps:
10+
# This action sets the current path to the root of your github repo
11+
- uses: actions/checkout@v4
12+
13+
- name: Install pre-commit
14+
run: python3 -m pip install pre-commit
15+
16+
- name: Run hooks
17+
run: pre-commit run --all

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
_build
12
code/results
23
data/data.txt
34
code/figures

.pre-commit-config.yaml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.3.0
3+
rev: v4.5.0
44
hooks:
55
- id: check-yaml
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88
- id: check-docstring-first
99
- id: debug-statements
1010
- id: requirements-txt-fixer
11+
- id: check-added-large-files
12+
- id: check-toml
1113

12-
- repo: https://github.com/asottile/reorder_python_imports
13-
rev: v3.8.3
14+
- repo: https://github.com/asottile/add-trailing-comma
15+
rev: v3.1.0
1416
hooks:
15-
- id: reorder-python-imports
17+
- id: add-trailing-comma
1618

1719
- repo: https://github.com/psf/black
18-
rev: 22.10.0
20+
rev: 23.10.1
1921
hooks:
2022
- id: black
2123

22-
- repo: https://github.com/pre-commit/pre-commit-hooks
23-
rev: v2.0.0
24+
- repo: https://github.com/charliermarsh/ruff-pre-commit
25+
# Ruff version.
26+
rev: 'v0.1.4'
2427
hooks:
25-
- id: flake8
28+
- id: ruff
2629

27-
- repo: https://github.com/asottile/add-trailing-comma
28-
rev: v2.3.0
29-
hooks:
30-
- id: add-trailing-comma
3130

3231
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: v0.982
32+
rev: v1.6.1
3433
hooks:
3534
- id: mypy
36-
37-
- repo: https://github.com/asottile/pyupgrade
38-
rev: v3.1.0
39-
hooks:
40-
- id: pyupgrade
41-
args: [--py38-plus]

docs/_config.yml renamed to _config.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# Learn more at https://jupyterbook.org/customize/config.html
33

44
title: Example paper
5-
author: Henrik Finsberg
6-
logo: "logo.png"
7-
copyright: "2022"
5+
author: Henrik Finsberg and Jørgen Dokken
6+
logo: "docs/logo.png"
7+
copyright: "2023"
8+
only_build_toc_files: true
89

910
# Force re-execution of notebooks on each build.
1011
# See https://jupyterbook.org/content/execute.html
@@ -31,12 +32,24 @@ parse:
3132
- dollarmath
3233
- linkify
3334

35+
3436
sphinx:
3537
config:
36-
bibtex_bibfiles: ["refs.bib"]
38+
bibtex_bibfiles: ["docs/refs.bib"]
39+
nb_execution_show_tb: True
40+
html_theme_options:
41+
navigation_with_keys: false
42+
html_last_updated_fmt: "%b %d, %Y"
43+
nb_custom_formats: # https://jupyterbook.org/en/stable/file-types/jupytext.html#file-types-custom
44+
.py:
45+
- jupytext.reads
46+
- fmt: py
3747

3848
extra_extensions:
3949
- 'sphinx.ext.autodoc'
4050
- 'sphinx.ext.napoleon'
4151
- 'sphinx.ext.viewcode'
4252
- "sphinxcontrib.bibtex"
53+
54+
55+
exclude_patterns: [".pytest_cache/*", ".github/*"]

_toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
format: jb-book
2+
root: README
3+
4+
chapters:
5+
- file: docs/abstract
6+
- file: docs/reproducing
7+
- file: code/demo
8+
- file: docs/citation

code/demo.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# ---
2+
# jupyter:
3+
# jupytext:
4+
# text_representation:
5+
# extension: .py
6+
# format_name: light
7+
# format_version: '1.5'
8+
# jupytext_version: 1.15.2
9+
# kernelspec:
10+
# display_name: Python 3.10.6 64-bit ('3.10.6')
11+
# language: python
12+
# name: python3
13+
# ---
14+
# # Demo
15+
#
16+
# This notebook contains a simple demo on how to work with the code.
17+
import sys
18+
19+
sys.path.insert(0, "../code")
20+
21+
# +
22+
import numpy as np
23+
from scipy.integrate import solve_ivp
24+
import ap_features as apf
25+
26+
from run_simulation import fitzhugh_nagumo
27+
28+
# +
29+
a = -0.22
30+
b = 1.17
31+
time = np.arange(0, 1000.0, 1.0)
32+
33+
res = solve_ivp(
34+
fitzhugh_nagumo,
35+
[0, 1000.0],
36+
[0, 0],
37+
args=(a, b),
38+
t_eval=time,
39+
)
40+
41+
v_all = apf.Beats(y=res.y[0, :], t=time)
42+
w_all = apf.Beats(y=res.y[1, :], t=time)
43+
# -
44+
45+
v_all.plot()
46+
47+
w_all.plot()
48+
49+
v = v_all.average_beat()
50+
print(v.apd(50))
51+
v.plot()
52+
53+
w = w_all.average_beat()
54+
print(w.apd(50))
55+
w.plot()

0 commit comments

Comments
 (0)