Skip to content

Commit 00ae6cf

Browse files
committed
Merge branch 'master' into manual-dispatch
2 parents 67010a4 + 5bd44dc commit 00ae6cf

16 files changed

+102
-3475
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
5656
# Deploy the book's HTML to gh-pages branch
5757
- name: GitHub Pages action
58-
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501
58+
uses: peaceiris/actions-gh-pages@v3
5959
with:
6060
github_token: ${{ secrets.GITHUB_TOKEN }}
6161
publish_dir: ./book/_build/html

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ stock.csv
2222
.venv
2323
.venv/
2424
book/_build
25+
.DS_Store

Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
FROM debian:bullseye-slim
1+
FROM debian:bookworm-slim
22

3-
RUN apt-get update -y && apt-get install -y texlive-xetex latexmk texlive-xetex \
4-
texlive-fonts-extra fonts-freefont-otf python3 python3-pip git zile wget
3+
#RUN apt-get update -y && apt-get install -y texlive-xetex latexmk texlive-xetex \
4+
# texlive-fonts-extra fonts-freefont-otf python3 python3-pip git zile wget
55

6-
COPY poetry.lock pyproject.toml /opt/
6+
RUN apt-get update -y && apt-get install -y python3 python3-pip texlive-xetex \
7+
latexmk git zile wget texlive-fonts-extra python3-venv
78

8-
RUN pip install poetry==1.1.4
9+
COPY requirements.txt /opt/
910

1011
WORKDIR /opt/
11-
RUN poetry config virtualenvs.create false
12-
RUN poetry install -vvv
12+
RUN python3 -m venv venv
13+
RUN . venv/bin/activate && pip install -r requirements.txt
14+
RUN . venv/bin/activate && pip list
15+
# activate venv
16+
ENV PATH="/opt/venv/bin:$PATH"
1317

1418
RUN mkdir -p /io
1519
WORKDIR /io
1620

1721
# Need this for one nbval and chapter 1
1822
RUN ln -s /usr/bin/python3 /usr/local/bin/python
1923

24+
# supress warning when running jupyter-book in container
25+
ENV PYDEVD_DISABLE_FILE_VALIDATION=1
2026
CMD ["/bin/bash"]

Makefile

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ all:
33
make pdf
44

55
install:
6-
poetry install -vvv
6+
pip install -r requirements.txt
77

88
clean:
99
cd book; rm -rf \
@@ -13,20 +13,20 @@ clean:
1313
_build .ipynb_checkpoints
1414

1515
html:
16-
poetry run jupyter-book build book --builder html
16+
jupyter-book build book --builder html
1717

1818
linkcheck:
19-
poetry run jupyter-book build book --builder linkcheck
19+
jupyter-book build book --builder linkcheck
2020

2121
pdf: book/*-*.ipynb
22-
poetry run jupyter-book build book --builder pdflatex
22+
jupyter-book build book --builder pdflatex
2323

2424
nbval:
2525
@echo "Testing all chapters (apart from 18) with --nbval"
26-
poetry run pytest -v --nbval book --sanitize-with book/static/nbval_sanitize.cfg \
26+
pytest -v --nbval book --sanitize-with book/static/nbval_sanitize.cfg \
2727
--ignore=book/18-environments.ipynb --ignore=book/_build
2828
@echo "Testing chapter 18 with --nbval-lax"
29-
poetry run pytest -v --nbval-lax book/18-environments.ipynb
29+
pytest -v --nbval-lax book/18-environments.ipynb
3030

3131

3232

@@ -44,16 +44,8 @@ docker-build:
4444
docker-build-nocache:
4545
docker build -t python4compscience2 --no-cache .
4646

47-
# Here we only bind the required directories and files into the docker container
48-
# at runtime to avoid potential conflicts with local files
49-
5047
define DOCKER_RUN
51-
docker run --workdir=/io \
52-
-v $(CURDIR)/book:/io/book \
53-
-v $(CURDIR)/Makefile:/io/Makefile \
54-
-v $(CURDIR)/poetry.lock:/io/poetry.lock \
55-
-v $(CURDIR)/pyproject.toml:/io/pyproject.toml \
56-
python4compscience
48+
docker run --rm -v $(CURDIR):/io python4compscience
5749
endef
5850

5951
docker-bash:

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ and schools. Please send a message to the author if you do so.
119119

120120
Hans Fangohr is a researcher and teacher (see
121121
[homepage](https://fangohr.github.io), [blog](https://fangohr.github.io/blog),
122-
[twitter](https://twitter.com/ProfCompMod)). His interests include effective
122+
[mastodon](https://fosstodon.org/@ProfCompMod)). His interests include effective
123123
software engineering for computational science and data science, researching
124124
computational modelling and data analysis methods, and education. He is a
125125
Professor at the [University of Southampton (UK)](https://www.southampton.ac.uk)

book/12-symbolic-computation.ipynb

Lines changed: 22 additions & 21 deletions
Large diffs are not rendered by default.

book/14-numpy.ipynb

Lines changed: 4 additions & 6 deletions
Large diffs are not rendered by default.

book/15-visualising-data.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"For more detailed information, check these links\n",
2929
"\n",
3030
"- A very nice introduction in the object oriented Matplotlib interface, and summary of all important ways of changing style, figure size, linewidth, etc. This is a useful reference:\n",
31-
" <https://nbviewer.ipython.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb>\n",
31+
" <https://github.com/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb>\n",
3232
"\n",
3333
"- [Matplotlib tutorial](https://matplotlib.org/stable/tutorials/index)\n",
3434
"\n",
@@ -46,7 +46,7 @@
4646
"\n",
4747
"This chapter focusses on the Pylab interface, but also provides examples for the object-oriented `matplotlib.pyplot` interface.\n",
4848
"\n",
49-
"An excellent introduction and overview of the `matplotlib.pyplot` plotting interface is available in <https://nbviewer.ipython.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb>."
49+
"An excellent introduction and overview of the `matplotlib.pyplot` plotting interface is available in <https://github.com/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb>."
5050
]
5151
},
5252
{
@@ -1135,7 +1135,7 @@
11351135
"\n",
11361136
"I would speculate that increasingly we will be using high-level plotting tools (such as pandas, xarray, holoviews) to explore data interactively.\n",
11371137
"\n",
1138-
"We can see a trend in data analysis libraries that data objects can be converted to such high-level annotated data objecs (such as European XFEL's [extra-data](https://extra-data.readthedocs.io) tools which can return a labelled xarray object). Other projects combine the metadata with the data in custom made objects to then provide convenience methods (such as [Ubermag](http://ubermag.github.io)'s [discretisedfield](https://ubermag.github.io/documentation/ipynb/discretisedfield/field-matplotlib-visualisation.html) object).\n",
1138+
"We can see a trend in data analysis libraries that data objects can be converted to such high-level annotated data objecs (such as European XFEL's [extra-data](https://extra-data.readthedocs.io) tools which can return a labelled xarray object). Other projects combine the metadata with the data in custom made objects to then provide convenience methods (such as [Ubermag](http://ubermag.github.io)'s [discretisedfield](discretisedfield/field-matplotlib-visualisation.html) object).\n",
11391139
"\n",
11401140
"Will we still need to learn the basics, such as the `matplotlib.pyplot` interface? Probably yes: the very least to fine tune the plots provided by these high level libraries: \n",
11411141
"\n"
@@ -1261,7 +1261,7 @@
12611261
"name": "python",
12621262
"nbconvert_exporter": "python",
12631263
"pygments_lexer": "ipython3",
1264-
"version": "3.10.1"
1264+
"version": "3.9.13"
12651265
}
12661266
},
12671267
"nbformat": 4,

book/16-scipy.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@
10431043
"import scipy.fft\n",
10441044
"import numpy as np\n",
10451045
"import matplotlib.pyplot as plt\n",
1046-
"pi = scipy.pi\n",
1046+
"pi = np.pi\n",
10471047
"\n",
10481048
"signal_length = 0.5 # [seconds]\n",
10491049
"sample_rate = 500 # sampling rate [Hz]\n",
@@ -1310,7 +1310,7 @@
13101310
"source": [
13111311
"Note that there are other functions to read from and write to in formats as used by IDL, Netcdf and other formats in `scipy.io`.\n",
13121312
"\n",
1313-
"More → see [Scipy tutorial](https://docs.scipy.org/doc/scipy/reference/tutorial/io.html)."
1313+
"More → see [Scipy tutorial](https://docs.scipy.org/doc/scipy/reference/io.html)."
13141314
]
13151315
}
13161316
],
@@ -1330,9 +1330,9 @@
13301330
"name": "python",
13311331
"nbconvert_exporter": "python",
13321332
"pygments_lexer": "ipython3",
1333-
"version": "3.9.7"
1333+
"version": "3.9.13"
13341334
}
13351335
},
13361336
"nbformat": 4,
13371337
"nbformat_minor": 1
1338-
}
1338+
}

book/17-pandas.ipynb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"cell_type": "markdown",
125125
"metadata": {},
126126
"source": [
127-
"In a way, the keys of the dictionary contain the stock labels and the values contain the actual values:"
127+
"The keys of the dictionary contain the stock labels and the values contain the actual values:"
128128
]
129129
},
130130
{
@@ -189,7 +189,7 @@
189189
"cell_type": "markdown",
190190
"metadata": {},
191191
"source": [
192-
"The Pandas Series object address the requriments above. It is similar to a dictionary, but with improvements for the given problem:\n",
192+
"The Pandas Series object address the requirements above. It is similar to a dictionary, but with improvements for the given problem:\n",
193193
"\n",
194194
"* the order of the items is maintained\n",
195195
"* the values have to have the same type (higher execution performance)\n",
@@ -342,11 +342,11 @@
342342
"outputs": [],
343343
"source": [
344344
"%matplotlib inline\n",
345-
"# settings for jupyter book: svg for html version, high-resolution png for pdf\n",
346-
"from IPython.display import set_matplotlib_formats\n",
347-
"set_matplotlib_formats('svg', 'png')\n",
348-
"import matplotlib as mpl\n",
349-
"mpl.rcParams['figure.dpi'] = 400"
345+
"# settings for Jupyter book: svg for html version, high-resolution png for pdf\n",
346+
"import matplotlib\n",
347+
"import matplotlib_inline\n",
348+
"matplotlib_inline.backend_inline.set_matplotlib_formats('svg', 'png')\n",
349+
"matplotlib.rcParams['figure.dpi'] = 400"
350350
]
351351
},
352352
{
@@ -607,7 +607,7 @@
607607
"source": [
608608
"## Plotting data\n",
609609
"\n",
610-
"Commonly used plots are easily accessible via the `plot()` method of the Series object. We have seen a bar plot above already. The `Series.plot()` method accepts an argument `kind` such as `kind=\"bar\"`, but there is an equivalent method `Series.plot.bar()` avaialble.\n",
610+
"Commonly used plots are easily accessible via the `plot()` method of the Series object. We have seen a bar plot above already. The `Series.plot()` method accepts an argument `kind` such as `kind=\"bar\"`, but there is an equivalent method `Series.plot.bar()` available.\n",
611611
"\n",
612612
"Further examples:"
613613
]
@@ -656,7 +656,7 @@
656656
"cell_type": "markdown",
657657
"metadata": {},
658658
"source": [
659-
"We can also fetch the data from the series and drive the plotting \"manually\" ourselves:"
659+
"We can also retrieve the data from the series and drive the plotting \"manually\" ourselves:"
660660
]
661661
},
662662
{
@@ -667,8 +667,8 @@
667667
"source": [
668668
"import matplotlib.pyplot as plt\n",
669669
"\n",
670-
"names = list(stock.index)\n",
671-
"values = list(stock.values)\n",
670+
"names = list(stock.index) # conversion to list not necessary \n",
671+
"values = list(stock.values) # conversion to list not necessary\n",
672672
"\n",
673673
"fig, ax = plt.subplots(1, 1, figsize=(9, 3))\n",
674674
"ax.bar(names, values)\n",
@@ -1788,7 +1788,7 @@
17881788
"metadata": {
17891789
"anaconda-cloud": {},
17901790
"kernelspec": {
1791-
"display_name": "Python 3",
1791+
"display_name": "Python 3 (ipykernel)",
17921792
"language": "python",
17931793
"name": "python3"
17941794
},
@@ -1802,9 +1802,9 @@
18021802
"name": "python",
18031803
"nbconvert_exporter": "python",
18041804
"pygments_lexer": "ipython3",
1805-
"version": "3.8.6-final"
1805+
"version": "3.9.13"
18061806
}
18071807
},
18081808
"nbformat": 4,
18091809
"nbformat_minor": 2
1810-
}
1810+
}

0 commit comments

Comments
 (0)