Skip to content

Commit 2b6272d

Browse files
DOC add vector field in MSA example (#206)
* DOC add vector field in MSA example * pixi doc-build
1 parent 122d00f commit 2b6272d

File tree

7 files changed

+38
-13
lines changed

7 files changed

+38
-13
lines changed

.github/workflows/asv.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
os: [ubuntu-latest, windows-latest, macos-latest, ubuntu-24.04-arm]
1919

2020
steps:
21-
- uses: actions/checkout@v5
21+
- uses: actions/checkout@v6
2222
with:
2323
fetch-depth: 0
2424

@@ -61,7 +61,7 @@ jobs:
6161
url: ${{ steps.deployment.outputs.page_url }}
6262

6363
steps:
64-
- uses: actions/checkout@v5
64+
- uses: actions/checkout@v6
6565
with:
6666
fetch-depth: 0
6767

@@ -70,7 +70,7 @@ jobs:
7070
run: git branch main origin/main
7171

7272
- name: Prepare previous ASV results
73-
uses: actions/checkout@v5
73+
uses: actions/checkout@v6
7474
continue-on-error: true
7575
with:
7676
ref: gh-pages

.github/workflows/emscripten.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
build-wasm-wheel:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v5
10+
- uses: actions/checkout@v6
1111
- name: Build WASM wheel
1212
uses: pypa/[email protected]
1313
env:

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v5
11+
- uses: actions/checkout@v6
1212
- uses: prefix-dev/[email protected]
1313
with:
1414
environments: static

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616

1717
steps:
18-
- uses: actions/checkout@v5
18+
- uses: actions/checkout@v6
1919
- uses: prefix-dev/[email protected]
2020
with:
2121
environments: >-
@@ -39,8 +39,8 @@ jobs:
3939
- name: Test with doctest
4040
if: matrix.os == 'ubuntu-latest'
4141
run: |
42-
pixi run -e docs doc
43-
pixi run -e docs doc sphinx-build doctest
42+
pixi run -e docs doc-build
43+
pixi run -e docs doc-build sphinx-build doctest
4444
- name: Test nogil
4545
run: |
4646
pixi run -e nogil nogil-eta

.github/workflows/wheel.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
build-sdist:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v5
10+
- uses: actions/checkout@v6
1111
- uses: prefix-dev/[email protected]
1212
with:
1313
environments: dev
@@ -31,7 +31,7 @@ jobs:
3131
os: [ubuntu-latest, windows-latest, macos-latest, ubuntu-24.04-arm]
3232
runs-on: ${{ matrix.os }}
3333
steps:
34-
- uses: actions/checkout@v5
34+
- uses: actions/checkout@v6
3535
- name: Build wheels
3636
uses: pypa/[email protected]
3737
env:

examples/plot_narx_msa.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# where :math:`y` is the output signal and :math:`u` is the input signal, which is
2525
# :math:`u(t) = 2.5\cos(2\pi t)`.
2626
#
27-
# The phase portraits of the Duffing equation are shown below.
27+
# The phase portraits and the vector field of the Duffing equation are shown below.
2828

2929
import matplotlib.pyplot as plt
3030
import numpy as np
@@ -67,10 +67,35 @@ def auto_duffing_equation(y, t):
6767
for i in range(n_init):
6868
sol[i] = odeint(auto_duffing_equation, y0[i], t)
6969

70+
# Phase portraits
7071
for i in range(n_init):
7172
plt.plot(sol[i, :, 0], sol[i, :, 1], c="tab:blue")
7273

73-
plt.title("Phase portraits of Duffing equation")
74+
# Vector field
75+
y_min = np.min(sol[:, :, 0])-0.2
76+
y_max = np.max(sol[:, :, 0])+0.2
77+
dot_y_min = np.min(sol[:, :, 1])-0.2
78+
dot_y_max = np.max(sol[:, :, 1])+0.2
79+
y, dot_y = np.meshgrid(
80+
np.linspace(y_min, y_max, 30), np.linspace(dot_y_min, dot_y_max, 30)
81+
)
82+
ddot_y = auto_duffing_equation([y, dot_y], 0)[1]
83+
plt.streamplot(
84+
y,
85+
dot_y,
86+
dot_y,
87+
ddot_y,
88+
color=(0.5, 0.5, 0.5, 0.3),
89+
density=1.5,
90+
minlength=0.02,
91+
maxlength=0.1,
92+
linewidth=0.5,
93+
arrowsize=0.5,
94+
)
95+
96+
plt.xlim(y_min, y_max)
97+
plt.ylim(dot_y_min, dot_y_max)
98+
plt.title("Phase portraits and vector field of Duffing equation")
7499
plt.xlabel("y(t)")
75100
plt.ylabel("dy/dt(t)")
76101
plt.show()

pixi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ type = { cmd = "mypy . --ignore-missing-imports", cwd = "fastcan" }
113113
spell = "codespell fastcan"
114114

115115
[feature.docs.tasks]
116-
doc = { cmd = "{{ SPHINXBUILD }} -M {{ CMD }} {{ SOURCEDIR }} {{ BUILDDIR }} {{ SPHINXOPTS }} --fail-on-warning", cwd = "doc", args = [{ arg = "SPHINXBUILD", default = "sphinx-build" }, { arg = "CMD", default = "html" }, { arg = "SOURCEDIR", default = "." }, { arg = "BUILDDIR", default = "_build" }, { arg = "SPHINXOPTS", default = "" }] }
116+
doc-build = { cmd = "{{ SPHINXBUILD }} -M {{ CMD }} {{ SOURCEDIR }} {{ BUILDDIR }} {{ SPHINXOPTS }} --fail-on-warning", cwd = "doc", args = [{ arg = "SPHINXBUILD", default = "sphinx-build" }, { arg = "CMD", default = "html" }, { arg = "SOURCEDIR", default = "." }, { arg = "BUILDDIR", default = "_build" }, { arg = "SPHINXOPTS", default = "" }] }
117117
doc-clean = { cmd = "rm -rf {{ BUILDDIR }} generated auto_examples jupyterlite_contents .jupyterlite.doit.db _contents _output .cache", cwd = "doc", args = [{ arg = "BUILDDIR", default = "_build" }] }
118118
doc-deploy = { cmd = "python -m http.server" , cwd = "doc/_build/html" }
119119
doc-plantuml = { cmd = "plantuml -tsvg {{ SOURCE }} -o {{ OUTPUT }}", cwd = "doc", args = [{ arg = "SOURCE", default = "diagram.puml" }, { arg = "OUTPUT", default = "_build" }] }

0 commit comments

Comments
 (0)