You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-14Lines changed: 27 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
Thank you for taking our course. Completing the following tasks will prepare you for the exercise sessions in the coming weeks. Machine learning on larger scales often requires using central compute clusters, which run on Linux. Consequently, we will use workstations running Ubuntu (a Linux distribution). We highly recommend to use Linux systems instead of Windows.
3
3
4
4
5
-
### Task 1: Setting up your repository.
5
+
### ⊙ Task 1: Setting up your repository.
6
6
- Configure GitHub for ssh access. You need to generate a key pair and add the public key to your GitHub account.
7
7
- To generate your key follow the steps [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent). For Ubuntu the necessary steps are:
8
8
1. Open a terminal by pressing `Ctrl+Alt+T`.
@@ -23,7 +23,7 @@ Thank you for taking our course. Completing the following tasks will prepare you
23
23
24
24
In Vscode, you can now open a rendered version of this readme. Right-click the file and select`Open Preview`.
25
25
26
-
### Task 2: Downloading and installing Miniconda.
26
+
### ⊙ Task 2: Downloading and installing Miniconda.
27
27
To develop and execute our python code, we use a python container software called miniconda. Using miniconda you can create an `environment` which holds python and all the required software to run the given scripts.
28
28
- Navigate to https://docs.conda.io/en/latest/miniconda.html in your favourite browser.
29
29
The HRZ-Pool computers run Ubuntu Linux. Download the `Miniconda3 Linux 64-bit` file.
@@ -32,21 +32,21 @@ The HRZ-Pool computers run Ubuntu Linux. Download the `Miniconda3 Linux 64-bit`
32
32
- Finally, execute this command`source ~/.bashrc`. Check if you can see the `(base)` environment name on the left-hand side of your command line. This means that (mini)conda is installed correctly.
33
33
34
34
35
-
### Task 3: Setting up Vscode for Python development
35
+
### ⊙ Task 3: Setting up Vscode for Python development
36
36
- Open Visual Studio Code (Vscode).
37
37
- Click on the extensions tab in Vscode (on the left hand side)  or press `Ctrl+Shift+X`. Install the `Python` and `Remote-SSH` extensions. Choose the versions provided by Microsoft.
38
38
- Make the Miniconda interpreter your default in Vscode by pressing `Ctrl+Shift+P`. Type `select interpreter` and press enter. In the following dialogue, choose the `base` environment.
39
39
- (Optional) For the course, we suggest to install `TODO Highlight` extension provided by Wayou Liu. This is handy in identifying TODO parts of exercise much easier.
40
40
41
-
### Task 4: Installing dependencies
41
+
### ⊙ Task 4: Installing dependencies
42
42
- Open a terminal by pressing `Ctrl+Alt+T`. Navigate into this directory by typing `cd exercise-01-intro-yourgitname`. Type
43
43
44
44
```bash
45
45
pip install -r requirements.txt
46
46
```
47
47
to install the Python packages required for this exercise.
48
48
49
-
### Task 5: Test your code.
49
+
### ⊙ Task 5: Test your code.
50
50
Scientific software must provide reproducible results, and automatic testing ensures that our software runs reliably. For example, the recent [CrowdStrike incident](https://en.wikipedia.org/wiki/2024_CrowdStrike_incident), which won the 2024 '[Most Epic Fail](https://uk.pcmag.com/security/153845/crowdstrike-exec-shows-up-to-accept-most-epic-fail-award-in-person)' award highlights the importance of thorough testing.
51
51
52
52

@@ -61,37 +61,50 @@ To prevent similar issues, we strongly recommend testing your code. Let's learn
61
61
Click the `Configure Python Tests` button and select `pytest` in the ensuing prompt. In the next step, Vscode wants to know the location of the test folder. Choose `tests`.
62
62
Vscode will now display your tests on the sidebar on the left. Click the play symbol next to the tests folder to run all tests.
63
63
64
-
### Task 6: Implement and test a Python class.
65
-
- Open `src/my_code.py` and finish the `__init__` function of the `Complex` class. The idea here is to implement support for complex numbers (see: https://en.wikipedia.org/wiki/Complex_number for more information about complex numbers). Double-check your code by running `nox -s test`.
64
+
### ⊙ Task 6: Implement and test a Python class.
65
+
- Open `src/my_code.py` and finish the `__init__` function of the `Complex` class. The idea here is to implement support for complex numbers (see: https://en.wikipedia.org/wiki/Complex_number for more information about complex numbers). Double-check your code by running `nox -s test`.
66
66
67
-
### Task 7: Breakpoints
67
+
- In Python, the `__init__` function is a method that is automatically called when you create an object from a class. It sets up the initial values of the specific object. In this exercise, for instance, the `__init__` method will take on two values: The real part `x` ("realpart") and the imaginary part `y` ("imagpart"), since this is all you need to define any imaginary number `z`: $$z = x + i \cdot y$$
68
+
- The `self` parameter is a way for a class to refer to the specific object that is being used. So whenever you use `self.nameOfVariable` you are saying _This is the nameOfVariable of __this__ object_.
69
+
- After completing the `__init__` function, you can now create a new complex number via:
70
+
```bash
71
+
x = 5 # some number representing the real part
72
+
y = -6 # another number representing the imaginary part
73
+
z = Complex(x, y)
74
+
```
75
+
76
+
### ⊙ Task 7: Breakpoints
68
77
- Click on a line number in `my_code.py`. A red dot appears. Press the `debug_test` button in the `Testing` tab, Python will pause, and you can use the build-in `Debug console` to explore the data at this point.
69
78
70
-
### Task 8: Implement the remaining functions in my_code.py
79
+
### ⊙ Task 8: Implement the remaining functions in my_code.py
71
80
- Implement and test the `add`, `radius`, `angle`, and `multiply` functions.
81
+
- The formulas that you need are provided in the docstring (the comment that starts and ends with `"""` at the beginning of each method)
82
+
83
+
> **Remark**: Don't worry, this course is not about complex numbers! This task is just intended as a means to get used to the environment and coding in Python.
72
84
73
-
### Task 9: Plotting
85
+
### ⊙ Task 9: Plotting
74
86
- Run `python ./src/julia.py` to compute a plot of the Julia set with your `Complex` class (see: https://en.wikipedia.org/wiki/Julia_set for more information).
87
+
- The Julia set is a fractal pattern formed by repeatedly applying a mathematical rule to complex numbers, like $z = z^2 + c$, where `c` is an initial, fixed complex number.
75
88
- In `src/julia.py` use `plt.plot` and `plt.imshow` to visualize the julia-set. Feel free to play with `c` to create different sets.
76
89
77
90
78
-
### Task 10: Getting nox to help you format your code.
91
+
### ⊙ Task 10: Getting nox to help you format your code.
79
92
- Professionally written Python code respects coding conventions. Type `nox -s format` to have `nox` format your code for you.
80
93
81
-
### Optional Task 11: Linting
94
+
### ✪ Optional Task 11: Linting
82
95
- `nox` can do even more for you! A basic syntax error at the wrong place can cost days of computation time. Type
83
96
```bash
84
97
nox -s lint
85
98
```
86
99
to check your code for formatting issues and syntax errors.
87
100
88
-
### Optional Task 12: Typing
101
+
### ✪ Optional Task 12: Typing
89
102
- Take a look at https://docs.python.org/3/library/typing.html .`nox` can help you by checking your code fortype problems and incorrect functionsignatures.
90
103
```bash
91
104
nox -s typing
92
105
```
93
106
94
-
### Final Task 13: Finishing up the task
107
+
### ⊙ Final Task 13: Finishing up the task
95
108
At the end of the day after you finished all your tasks we want to save the results and upload them to your online GitHub repository. Ideally, all the tests were successful. Follow these steps:
96
109
- Open a terminal by pressing `Ctrl+Alt+T`. Navigate into this directory using the `cd` command.
0 commit comments