Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
47bb82a
updates to github actions for testing
mmcky Dec 1, 2020
0c1cced
update repository url
mmcky Dec 1, 2020
55e0b01
see if checkout needs credentials
mmcky Dec 1, 2020
ba031c9
new approach
mmcky Dec 1, 2020
85f5bfe
test commit to branch add-binder on notebooks repo
mmcky Dec 1, 2020
a49cb0d
fix git branch
mmcky Dec 1, 2020
22b590d
fix git commands
mmcky Dec 1, 2020
303105f
fix git link
mmcky Dec 1, 2020
143c3d7
make sure git uses ssh to pull
mmcky Dec 1, 2020
ff41aef
try using actions/checkout
mmcky Dec 1, 2020
5b4d2f2
fix
mmcky Dec 1, 2020
bd66473
change to use PAT
mmcky Dec 1, 2020
2cbde90
add more status
mmcky Dec 1, 2020
f7ac5fd
check path
mmcky Dec 1, 2020
629289d
update checkout path
mmcky Dec 1, 2020
f387016
check path in with
mmcky Dec 1, 2020
0caa233
try PAT
mmcky Dec 1, 2020
6874256
try new path outside of repo
mmcky Dec 1, 2020
8a6d56e
update git commands
mmcky Dec 1, 2020
b9b9282
check new link
mmcky Dec 1, 2020
2771ede
setup cp path
mmcky Dec 1, 2020
2a31ab3
fix repo link
mmcky Dec 1, 2020
eeffd72
check if push is causing the issue
mmcky Dec 2, 2020
8cc89bd
test using marketplace action
mmcky Dec 2, 2020
54841b3
update branch name for testing
mmcky Dec 2, 2020
9654da3
setup specific files to sync
mmcky Dec 2, 2020
41bd33c
preserve README and config for updates in lecture-python-programming.…
mmcky Dec 2, 2020
c7409ad
refine cp command
mmcky Dec 2, 2020
a175ada
list contens of prep folder
mmcky Dec 2, 2020
53a0af5
issue with . directories for git sync
mmcky Dec 2, 2020
4a30da5
fix typo
mmcky Dec 2, 2020
99085f0
move environment to root level
mmcky Dec 2, 2020
60ad23d
Merge branch 'master' into add-binder
mmcky Dec 3, 2020
5283407
migrate from code-block to literal for compat with sphinx-tojupyter
mmcky Dec 3, 2020
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build Project [using jupyter-book]
on: [push]
jobs:
tests:
preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
47 changes: 35 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ on:
push:
branches:
- master
- add-binder
jobs:
tests:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -24,19 +25,41 @@ jobs:
- name: Display Pip Versions
shell: bash -l {0}
run: pip list
- name: Build HTML
shell: bash -l {0}
run: |
jb build lectures --path-output ./
# - name: Build HTML
# shell: bash -l {0}
# run: |
# jb build lectures --path-output ./
- name: Build Download Notebooks (sphinx-tojupyter)
shell: bash -l {0}
run: |
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter
mkdir _build/html/_notebooks
cp _build/jupyter/*.ipynb _build/html/_notebooks
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
# - name: Copy Download Notebooks for GH-PAGES
# shell: bash -l {0}
# run: |
# mkdir _build/html/_notebooks
# cp _build/jupyter/*.ipynb _build/html/_notebooks
# - name: Deploy to gh-pages
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: _build/html/
# cname: python-programming.quantecon.org
- name: Prepare lecture-python-programming.notebooks sync
shell: bash -l {0}
run: |
mkdir -p _build/lecture-python-programming.notebooks
cp -a _notebook_repo/. _build/lecture-python-programming.notebooks
cp _build/jupyter/*.ipynb _build/lecture-python-programming.notebooks
ls -a _build/lecture-python-programming.notebooks
- name: Commit latest notebooks to lecture-python-programming.notebooks
uses: cpina/github-action-push-to-another-repository@master
env:
API_TOKEN_GITHUB: ${{ secrets.QUANTECON_SERVICES_PAT }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/html/
cname: python-programming.quantecon.org
source-directory: '_build/lecture-python-programming.notebooks/'
destination-repository-username: 'QuantEcon'
destination-repository-name: 'lecture-python-programming.notebooks'
target-branch: 'update-notebooks'
commit-message: 'auto publishing updates to notebooks'
destination-github-username: 'quantecon-services'
user-email: services@quantecon.org
7 changes: 7 additions & 0 deletions _notebook_repo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# lecture-python-programming.notebooks

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/QuantEcon/lecture-python-programming.notebooks/master)

Notebooks for https://python-programming.quantecon.org

**Note:** This README should be edited [here](https://github.com/quantecon/lecture-python-programming.myst/.binder)
17 changes: 17 additions & 0 deletions _notebook_repo/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: lecture-python-programming
channels:
- default
dependencies:
- python=3.8
- anaconda
- pip
- pip:
- git+https://github.com/executablebooks/jupyter-book.git
- sphinxext-rediraffe
- git+https://github.com/executablebooks/sphinx-multitoc-numbering
- git+https://github.com/executablebooks/sphinx-exercise.git
- joblib
- interpolation
- git+https://github.com/QuantEcon/sphinx-tojupyter.git
- git+https://github.com/QuantEcon/quantecon-book-theme.git

10 changes: 5 additions & 5 deletions lectures/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,31 +364,31 @@ One library we'll be using is [QuantEcon.py](http://quantecon.org/quantecon-py).
You can install [QuantEcon.py](http://quantecon.org/quantecon-py) by
starting Jupyter and typing

```{code-block} ipython3
```ipython3
!conda install quantecon
```

into a cell.

Alternatively, you can type the following into a terminal

```{code-block} bash
```bash
conda install quantecon
```

More instructions can be found on the [library page](http://quantecon.org/quantecon-py).

To upgrade to the latest version, which you should do regularly, use

```{code-block} bash
```bash
conda upgrade quantecon
```

Another library we will be using is [interpolation.py](https://github.com/EconForge/interpolation.py).

This can be installed by typing in Jupyter

```{code-block} ipython3
```ipython3
!conda install -c conda-forge interpolation
```

Expand Down Expand Up @@ -516,7 +516,7 @@ As the 1st task, try

For example, if you've installed the command line version, open up a terminal and enter.

```{code-block} bash
```bash
git clone https://github.com/QuantEcon/QuantEcon.py
```

Expand Down
2 changes: 1 addition & 1 deletion lectures/need_for_speed.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Compiled languages avoid these overheads with explicit, static types.

For example, consider the following C code, which sums the integers from 1 to 10

```{code-block} c
```c
#include <stdio.h>

int main(void) {
Expand Down
4 changes: 2 additions & 2 deletions lectures/pandas.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Let's look at an example that reads data from the CSV file `pandas/data/test_pwt

Here's the content of `test_pwt.csv`

```{code-block} none
```
"country","country isocode","year","POP","XRAT","tcgdp","cc","cg"
"Argentina","ARG","2000","37335.653","0.9995","295072.21869","75.716805379","5.5788042896"
"Australia","AUS","2000","19053.186","1.72483","541804.6521","67.759025993","6.7200975332"
Expand Down Expand Up @@ -292,7 +292,7 @@ For example, suppose that we are interested in the [unemployment rate](https://r
Via FRED, the entire series for the US civilian unemployment rate can be downloaded directly by entering
this URL into your browser (note that this requires an internet connection)

```{code-block} none
```
https://research.stlouisfed.org/fred2/series/UNRATE/downloaddata/UNRATE.csv
```

Expand Down
10 changes: 5 additions & 5 deletions lectures/python_advanced_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ All iterators can be placed to the right of the `in` keyword in `for` loop state

In fact this is how the `for` loop works: If we write

```{code-block} python3
```python3
for x in iterator:
<code block>
```
Expand All @@ -155,7 +155,7 @@ then the interpreter

So now you know how this magical looking syntax works

```{code-block} python3
```python3
f = open('somefile.txt', 'r')
for line in f:
# do something
Expand Down Expand Up @@ -526,7 +526,7 @@ We are now working in the module `__main__`, and hence the namespace for `__main

Next, we import a module called `amodule`

```{code-block} python3
```python3
import amodule
```

Expand Down Expand Up @@ -1660,7 +1660,7 @@ Write a function to recursively compute the $t$-th Fibonacci number for any $t$.

Complete the following code, and test it using [this csv file](https://raw.githubusercontent.com/QuantEcon/lecture-python-programming/master/source/_static/lecture_specific/python_advanced_features/test_table.csv), which we assume that you've put in your current working directory

```{code-block} python3
```python3
def column_iterator(target_file, column_number):
"""A generator function for CSV files.
When called with a file name target_file (string) and column number
Expand All @@ -1680,7 +1680,7 @@ for date in dates:

Suppose we have a text file `numbers.txt` containing the following lines

```{code-block} none
```
prices
3
8
Expand Down
4 changes: 2 additions & 2 deletions lectures/python_by_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ easily enough if you look around.

On this machine, it's located in

```{code-block} ipython
```ipython
anaconda3/lib/python3.7/site-packages/numpy
```

Expand Down Expand Up @@ -333,7 +333,7 @@ for animal in animals:
This example helps to clarify how the `for` loop works: When we execute a
loop of the form

```{code-block} python3
```python3
for variable_name in sequence:
<code block>
```
Expand Down
8 changes: 4 additions & 4 deletions lectures/python_essentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ Note that if `newfile.txt` is not in the present working directory then this cal

In this case, you can shift the file to the pwd or specify the [full path](https://en.wikipedia.org/wiki/Path_%28computing%29) to the file

```{code-block} python3
```python3
f = open('insert_full_path_to_file/newfile.txt', 'r')
```

Expand Down Expand Up @@ -620,7 +620,7 @@ After running this code, the docstring is available
f?
```

```{code-block} ipython
```ipython
Type: function
String Form:<function f at 0x2223320>
File: /home/john/temp/temp.py
Expand All @@ -632,7 +632,7 @@ Docstring: This function squares its argument
f??
```

```{code-block} ipython
```ipython
Type: function
String Form:<function f at 0x2223320>
File: /home/john/temp/temp.py
Expand Down Expand Up @@ -692,7 +692,7 @@ Here the function created by `lambda` is said to be *anonymous* because it was n

In a {ref}`previous lecture <python_by_example>`, you came across the statement

```{code-block} python3
```python3
plt.plot(x, 'b-', label="white noise")
```

Expand Down
4 changes: 2 additions & 2 deletions lectures/python_oop.md
Original file line number Diff line number Diff line change
Expand Up @@ -776,15 +776,15 @@ Implement $F_n$ as a class called `ECDF`, where

Your code should work as follows (modulo randomness)

```{code-block} python3
```python3
from random import uniform

samples = [uniform(0, 1) for i in range(10)]
F = ECDF(samples)
F(0.5) # Evaluate ecdf at x = 0.5
```

```{code-block} python3
```python3
F.observations = [uniform(0, 1) for i in range(1000)]
F(0.5)
```
Expand Down