@@ -3,8 +3,10 @@ jupytext:
33 text_representation :
44 extension : .md
55 format_name : myst
6+ format_version : 0.13
7+ jupytext_version : 1.16.4
68kernelspec :
7- display_name : Python 3
9+ display_name : Python 3 (ipykernel)
810 language : python
911 name : python3
1012---
@@ -38,7 +40,7 @@ In particular, as trade costs fall and international competition increases, inno
3840
3941Let's start with some imports:
4042
41- ``` {code-cell} ipython
43+ ``` {code-cell} ipython3
4244import numpy as np
4345import matplotlib.pyplot as plt
4446from numba import jit
@@ -335,7 +337,7 @@ These are the `@jit` statements that you see below (review [this lecture](https:
335337
336338Here's the main body of code
337339
338- ``` {code-cell} python3
340+ ``` {code-cell} ipython3
339341@jit(nopython=True)
340342def _hj(j, nk, s1, s2, θ, δ, ρ):
341343 """
@@ -651,9 +653,9 @@ The time series share parameters but differ in their initial condition.
651653
652654Here's the function
653655
654- ``` {code-cell} python3
656+ ``` {code-cell} ipython3
655657def plot_timeseries(n1_0, n2_0, s1=0.5, θ=2.5,
656- δ=0.7, ρ=0.2, ax=None, title=''):
658+ δ=0.7, ρ=0.2, ax=None, title=''):
657659 """
658660 Plot a single time series with initial conditions
659661 """
@@ -735,7 +737,8 @@ Replicate the figure {ref}`shown above <matsrep>` by coloring initial conditions
735737``` {solution-start} matsuyama_ex1
736738:class: dropdown
737739```
738- ``` {code-cell} python3
740+
741+ ``` {code-cell} ipython3
739742def plot_attraction_basis(s1=0.5, θ=2.5, δ=0.7, ρ=0.2, npts=250, ax=None):
740743 if ax is None:
741744 fig, ax = plt.subplots()
@@ -790,16 +793,21 @@ in real-time. Below we use an interactive plot to do this.
790793
791794Note, interactive plotting requires the [ ipywidgets] ( https://github.com/jupyter-widgets/ipywidgets ) module to be installed and enabled.
792795
793- ``` {code-cell} python3
796+ ``` {note}
797+ This interactive plot is disabled on this static webpage.
798+ In order to use this, we recommend to run this notebook locally.
799+ ```
800+
801+ ``` {code-cell} ipython3
802+ :class: no-execute
803+
794804def interact_attraction_basis(ρ=0.2, maxiter=250, npts=250):
795805 # Create the figure and axis that we will plot on
796806 fig, ax = plt.subplots(figsize=(12, 10))
797-
798807 # Create model and attraction basis
799808 s1, θ, δ = 0.5, 2.5, 0.75
800809 model = MSGSync(s1, θ, δ, ρ)
801810 ab = model.create_attraction_basis(maxiter=maxiter, npts=npts)
802-
803811 # Color map with colormesh
804812 unitrange = np.linspace(0, 1, npts)
805813 cf = ax.pcolormesh(unitrange, unitrange, ab, cmap="viridis")
@@ -809,11 +817,14 @@ def interact_attraction_basis(ρ=0.2, maxiter=250, npts=250):
809817 return None
810818```
811819
812- ``` {code-cell} python3
820+ ``` {code-cell} ipython3
821+ :class: no-execute
822+
813823fig = interact(interact_attraction_basis,
814824 ρ=(0.0, 1.0, 0.05),
815825 maxiter=(50, 5000, 50),
816826 npts=(25, 750, 25))
817827```
828+
818829``` {solution-end}
819830```
0 commit comments