Skip to content

Commit c5dbc60

Browse files
fix: remove %%capture from unstable lessons and add Lesson 0
- Remove %%capture Jupyter magic from unstable lesson .md files (incompatible with MyST rendering) - Add Lesson 0 (lesson0_tutorial.md) to the unstable section explaining how to set up the virtual environment and install all required dependencies (numpy, matplotlib) - Update unstable/README.md table of contents to include Lesson 0 - Update myst.yml TOC to include lesson0_tutorial.md in the Unstable section - Update AGENTS.md with MyST compatibility notes regarding %%capture
1 parent 1931e54 commit c5dbc60

10 files changed

Lines changed: 124 additions & 6 deletions

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ This script:
9191
- Fixes `attachment:` image syntax → plain relative paths
9292
- Handles both trailing-newline and no-trailing-newline source formats
9393

94+
### MyST Compatibility Notes
95+
96+
- **`%%capture` magic is not supported** in MyST text notebooks. The converter may produce cells containing `%%capture` (a Jupyter magic that suppresses output). These must be removed manually from the generated `.md` files, as MyST does not support this magic and the cell will fail to execute.
97+
- After regenerating with `convert_to_myst.py`, check all unstable `.md` files for `%%capture` and remove those lines.
98+
9499
---
95100

96101
## Building & Testing

myst.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ project:
4949
- title: "Unstable"
5050
children:
5151
- file: unstable/README.md
52+
- file: unstable/lesson0_tutorial.md
5253
- file: unstable/lesson1_tutorial.md
5354
- file: unstable/lesson2_tutorial.md
5455
- file: unstable/lesson3_tutorial.md

unstable/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ has changed from `.ipynb` to `.md` with `{code-cell}` directives.
1010

1111
| Number | Title and Link | Content |
1212
|--------|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
13+
| 0 | [](./lesson0_tutorial.md) | Setting up the virtual environment and installing all required dependencies. |
1314
| 1 | [](./lesson1_tutorial.md) | Basic operations in Python and `numpy` |
1415
| 2 | [](./lesson2_tutorial.md) | Learn about elements and operations in $\mathbb{R}^n$, $SO(n)$, and $SE(n)$ with $n\in{\{2,3\}}$ related to positions, orientations, and poses, respectively. |
1516
| 3 | [](./lesson3_tutorial.md) | Learn about the composition of rigid body motion in series to obtain the forward kinematics model of a robotic manipulator. |

unstable/lesson0_tutorial.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
kernelspec:
3+
name: python3
4+
display_name: 'Python 3'
5+
---
6+
7+
# L0 Setting up the virtual environment
8+
9+
*License: CC-BY-NC-SA 4.0*
10+
11+
*Author: Murilo M. Marinho (murilo.marinho@manchester.ac.uk)*
12+
13+
## Prerequisites for the learner
14+
This lesson has no prerequisites. It is designed to be the first lesson in the course.
15+
16+
## I found an issue
17+
Thank you! Please report it at https://github.com/MarinhoLab/OpenExecutableBooksRobotics/issues
18+
19+
# Introduction
20+
21+
Before starting with the lessons, you need to set up a suitable Python environment.
22+
This lesson guides you through creating a Python virtual environment and installing all the dependencies required for this project.
23+
24+
A **virtual environment** is an isolated Python environment that allows you to install packages without affecting your system-wide Python installation. This ensures reproducibility and avoids dependency conflicts.
25+
26+
# Creating a virtual environment
27+
28+
The recommended approach is to use Python's built-in `venv` module. Open a terminal and run:
29+
30+
```bash
31+
python3 -m venv venv
32+
```
33+
34+
This creates a directory called `venv` in your current working directory containing the virtual environment.
35+
36+
# Activating the virtual environment
37+
38+
Before installing packages or running the notebooks, activate the virtual environment:
39+
40+
### Linux / macOS
41+
```bash
42+
source venv/bin/activate
43+
```
44+
45+
### Windows (Command Prompt)
46+
```cmd
47+
venv\Scripts\activate.bat
48+
```
49+
50+
### Windows (PowerShell)
51+
```powershell
52+
venv\Scripts\Activate.ps1
53+
```
54+
55+
Once activated, your shell prompt should display `(venv)` to indicate the virtual environment is active.
56+
57+
# Installing the required packages
58+
59+
All lessons in this project use the following core dependencies:
60+
61+
- **numpy**: Numerical computing library for arrays, matrices, and linear algebra operations.
62+
- **matplotlib**: Plotting library used in later lessons for visualisation.
63+
64+
Run the following command to install them:
65+
66+
```bash
67+
pip install numpy matplotlib
68+
```
69+
70+
# Verifying the installation
71+
72+
You can verify that the packages are correctly installed by running the cell below.
73+
74+
````{code-cell}
75+
import numpy as np
76+
import matplotlib
77+
import matplotlib.pyplot as plt
78+
79+
print(f'numpy version: {np.__version__}')
80+
print(f'matplotlib version: {matplotlib.__version__}')
81+
````
82+
83+
# Building the documentation (optional)
84+
85+
To build the MyST documentation locally, you will also need:
86+
87+
```bash
88+
pip install mystmd jupyter-server ipykernel
89+
```
90+
91+
Then, from the repository root, run:
92+
93+
```bash
94+
myst build --html
95+
```
96+
97+
This produces the HTML output in `_build/html/`.
98+
99+
# Deactivating the virtual environment
100+
101+
When you are finished working, you can deactivate the virtual environment:
102+
103+
```bash
104+
deactivate
105+
```
106+
107+
# Summary
108+
109+
This lesson covered:
110+
111+
- Creating a Python virtual environment using `venv`.
112+
- Activating and deactivating the virtual environment.
113+
- Installing the required packages (`numpy` and `matplotlib`).
114+
- Verifying the installation.
115+
- Optional: Installing MyST build tools for local documentation builds.
116+
117+
Now you are ready to proceed to [Lesson 1](./lesson1_tutorial.md).

unstable/lesson1_tutorial.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ print(f't_phi={t_phi}')
183183
Just in case `numpy` is not already installed, we can install it with the following command. Nothing will happen if the library is already installed.
184184

185185
````{code-cell}
186-
%%capture
187186
%pip install numpy
188187
%pip install numpy --break-system-packages
189188
````

unstable/lesson2_tutorial.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Thank you! Please report it at https://github.com/MarinhoLab/OpenExecutableBooks
2222
# Installing prerequisites
2323

2424
````{code-cell}
25-
%%capture
2625
%pip install numpy
2726
%pip install numpy --break-system-packages
2827
````

unstable/lesson3_tutorial.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ kernelspec:
77
# Prerequisites
88

99
````{code-cell}
10-
%%capture
1110
%pip install numpy
1211
%pip install numpy --break-system-packages
1312
````

unstable/lesson4_tutorial.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ kernelspec:
77
# Package installation
88

99
````{code-cell}
10-
%%capture
1110
%pip install numpy
1211
%pip install numpy --break-system-packages
1312
````

unstable/lesson5_exercise_answers.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ kernelspec:
77
# Package installation
88

99
````{code-cell}
10-
%%capture
1110
%pip install numpy matplotlib
1211
%pip install numpy matplotlib --break-system-packages
1312
````

unstable/lesson5_tutorial.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ kernelspec:
77
# Package installation
88

99
````{code-cell}
10-
%%capture
1110
%pip install numpy matplotlib
1211
%pip install numpy matplotlib --break-system-packages
1312
````

0 commit comments

Comments
 (0)