Skip to content

Commit 6b0f67d

Browse files
Merge branch 'main' into mude-2025
2 parents d423adb + a4d7ffb commit 6b0f67d

File tree

2 files changed

+77
-7
lines changed

2 files changed

+77
-7
lines changed

book/version_control/notebooks.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Jupyter Notebooks: JSON-format
2+
3+
Jupyter notebooks, `ipynb`, are a special case in the discussion text vs binary. Because while the contents of your Markdown and code cells is saved as text in the file, the output of the code cells is sometimes a binary format. For example, if you create a plot using matplotlib and save the notebook, that plot output will be binary. This unfortunately makes it a little more difficult to use notebooks with version control, but if we are aware of the issue, it is not a problem---we will show you how.
4+
5+
If you tried opening up a notebook in the text editor you would have noticed a structure with curly braces, `{}`. This is [JSON-format](https://en.wikipedia.org/wiki/JSON)] (another file type), which the notebook uses to store information in each cell.
6+
7+
For example, the following two cells in a jupyter notebook:
8+
9+
```{code-cell}
10+
import numpy as np
11+
```
12+
13+
```{code-cell}
14+
np.linspace(0, 1, 10)
15+
```
16+
17+
Looks as follows:
18+
19+
```yaml
20+
{
21+
"cells": [
22+
{
23+
"cell_type": "code",
24+
"execution_count": 1,
25+
"id": "e7dcf271",
26+
"metadata": {},
27+
"outputs": [],
28+
"source": [
29+
"import numpy as np"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": 2,
35+
"id": "24165ce8",
36+
"metadata": {},
37+
"outputs": [
38+
{
39+
"data": {
40+
"text/plain": [
41+
"array([0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444,\n",
42+
" 0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ])"
43+
]
44+
},
45+
"execution_count": 2,
46+
"metadata": {},
47+
"output_type": "execute_result"
48+
}
49+
],
50+
"source": [
51+
"np.linspace(0, 1, 10)"
52+
]
53+
}
54+
],
55+
"metadata": {
56+
"kernelspec": {
57+
"display_name": "mude-base",
58+
"language": "python",
59+
"name": "python3"
60+
},
61+
"language_info": {
62+
"codemirror_mode": {
63+
"name": "ipython",
64+
"version": 3
65+
},
66+
"file_extension": ".py",
67+
"mimetype": "text/x-python",
68+
"name": "python",
69+
"nbconvert_exporter": "python",
70+
"pygments_lexer": "ipython3",
71+
"version": "3.12.11"
72+
}
73+
},
74+
"nbformat": 4,
75+
"nbformat_minor": 5
76+
}
77+
```

book/version_control/version_control.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ Try exploring a few files on your computer to confirm wether they are text-based
5454
Note that in Windows if you are using Notepad (the default), you will want to select "Word Wrap" under the "Format" menu to fit the contents of very long lines within the visible width of the window.
5555
```
5656

57-
### Jupyter Notebooks
58-
59-
Jupyter notebooks, `ipynb`, are a special case because while the contents of your Markdown and code cells is saved as text in the file, the output of the code cells is sometimes a binary format. For example, if you create a plot using matplotlib and save the notebook, that plot output will be binary. This unfortunately makes it a little more difficult to use notebooks with VCS, but if we are aware of the issue, it is not a problem---we will show you how.
60-
61-
If you tried opening up a notebook in the text editor you would have noticed a structure with curly braces, `{}`. This is [JSON-format](https://en.wikipedia.org/wiki/JSON)] (another file type), which the notebook uses to store information in each cell.
62-
63-
6457
## A different way of thinking?
6558

6659
As you will see in the other chapters on git, when applied to code, version control takes on a very different appearance than what you are used to with traditional backup software, for example, Microsoft Word auto-save, or cloud-based services like OneDrive, Dropbox or even [Visual Studio Code Share](../install/ide/vsc.md). All of these platforms are set up in a user-friendly way that is _focused on a single file._ This works fine when we are writing a report like a thesis. However, it does **not** work well when it comes to computer programs, because in addition to the files themselves, the _contents of the file_ become critical. As we will see, git is a version control software that allows us to compare and track changes in every character of text within a file, which is very useful when writing code, as well as working with a distributed team of collaborators.

0 commit comments

Comments
 (0)