Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modeling in Continuous Time Lectures #275

Merged
merged 20 commits into from
Jan 5, 2024
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
2 changes: 1 addition & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
style = "sciml"
margin = 84
margin = 80
yas_style_nesting = true
annotate_untyped_fields_with_any = false
7 changes: 5 additions & 2 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
push:
branches:
- main
schedule:
# Run monthly to avoid stale cache
- cron: '0 0 1 * *'
jobs:
cache:
runs-on: ubuntu-latest
Expand All @@ -12,7 +15,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11
- name: Install Python Dependencies
run: |
pip install -r requirements.txt
Expand All @@ -34,7 +37,7 @@ jobs:
- name: Set up Julia
uses: julia-actions/setup-julia@v1
with:
version: 1.9
version: 1.10.0
- name: Install IJulia and Setup Project
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11
- name: Install Python Dependencies
run: |
pip install -r requirements.txt
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Set up Julia
uses: julia-actions/setup-julia@v1
with:
version: 1.9
version: 1.10.0
- name: Install IJulia and Setup Project
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Julia
uses: julia-actions/setup-julia@v1
with:
version: 1.9
version: 1.10.0

- name: Install JuliaFormatter.jl
run: julia -e 'import Pkg; Pkg.add("JuliaFormatter")'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11
- name: Install Python Dependencies
run: |
pip install -r requirements.txt
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Set up Julia
uses: julia-actions/setup-julia@v1
with:
version: 1.9
version: 1.10.0
- name: Install IJulia and Setup Project
shell: bash
run: |
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
_build
us_cities.txt
us_cities.txt
.DS_Store
.vscode
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ It is straightforward to install the Jupyter Book and Julia software necessary f
7. Start a VS Code terminal with ``<Ctrl+`>`` or through any other method. Create a conda environment.

```bash
conda create -n lecture-julia.myst python=3.9
conda create -n lecture-julia.myst python=3.11
conda activate lecture-julia.myst
pip install -r requirements.txt
```
Expand Down Expand Up @@ -58,17 +58,17 @@ julia format_myst.jl lectures/getting_started_julia/getting_started.md
```

As a helper, you can call a shell script to do it for an entire folder

```bash
bash format_all_directory.sh lectures/dynamic_programming
```

or to also do the unicode substitutions

```bash
bash format_all_directory.sh lectures/dynamic_programming true
```

Alternatively, the formatter will run automatically when a pull-request is made


**(Optional) REPL Integration**
With [MyST-Markdown](https://github.com/executablebooks/myst-vs-code) and [Julia](https://marketplace.visualstudio.com/items?itemName=julialang.language-julia) installed, you can ensure that pressing `<Ctrl-Enter>` on lines of code are sent to a Julia REPL.
1. Open Key Bindings with `<Ctrl-K Ctrl-S>`.
Expand All @@ -84,6 +84,7 @@ If you installed the REPL Integration above, then in a `.md` file,
3. Then, assuming that you set up the keybindings above, you can send a line of code in the markdown to the REPL with `<Ctrl-Enter>`.

Code can be executed line by line, or you can select a chunk of code and execute it.

## Example Operations
### Building the lectures
To do a full build of the lectures:
Expand All @@ -100,7 +101,7 @@ jb build lectures

This will take a while. But it will populate your cache, so future iteration is faster.

On Windows, if you get the following error:
It is suggested to use WSL on Windows On Windows, if you get the following error:

```
ImportError: DLL load failed while importing win32api: The specified procedure could not be found.
Expand Down Expand Up @@ -132,5 +133,4 @@ jb clean lectures --all

After execution, you can find the generated `.ipynb` and `.jl` files in `_build/jupyter_execute` for each lecture.
- To see errors, you can open these in JupyterLab, the Jupyter support within VS Code, etc.
- If using the Julia REPL in VS Code, make sure to do `] activate lectures` prior to testing to ensure the packages are activated. This is not necessary when opening in Jupyter.
- Finally, the code is written using interactive scoping, so `include(_build/jupyter_execute/dynamic_programming/mccall_model.jl)` etc. may not work. However, `shift-enter` within VS Code to the REPL will work, and you can execute these with [SoftGlobalScope.jl](https://github.com/stevengj/SoftGlobalScope.jl) if strictly required.
- If using the Julia REPL in VS Code, make sure to do `] activate lectures` prior to testing to ensure the packages are activated. This is not necessary when opening in Jupyter.
4 changes: 3 additions & 1 deletion format_myst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ function format_myst(input_file_path, output_file_path, extra_replacements = fal
replacements = Dict("α" => "alpha", "β" => "beta", "γ" => "gamma", "≤" => "<=",
"≥" => ">=", "Σ" => "Sigma", "σ" => "sigma","μ"=>"mu","ϕ"=>"phi","ψ"=>"psi","ϵ"=>"epsilon",
"δ"=>"delta","θ" => "theta","ζ"=>"zeta","X̄" => "X_bar","p̄" => "p_bar","x̂" => "x_hat","λ"=>"lambda",
"ρ"=>"rho","u′" => "u_prime" , "f′"=>"f_prime"," ∂u∂c"=>"dudc","Π"=>"Pi","π"=>"pi"," ξ"=>"Xi","c̄"=>"c_bar","w̄"=>"w_bar")
"ρ"=>"rho","u′" => "u_prime" , "f′"=>"f_prime"," ∂u∂c"=>"dudc","Π"=>"Pi","π"=>"pi","ξ"=>"xi","c̄"=>"c_bar",
"w̄"=>"w_bar","Θ" => "Theta", "Ξ" =>"Xi", "Q̃" => "Q_tilde","R̃" => "R_tilde","Ã" => "A_tilde", "B̃" => "B_tilde",
"P̃" => "P_tilde","F̃" => "F_tilde","d̃" => "d_tilde")

# Replace the code blocks in the content and handle exceptions
try
Expand Down
Loading
Loading