Skip to content

Commit c4ca239

Browse files
committed
update text to match the new example; closes #1
1 parent e8a5fc2 commit c4ca239

File tree

11 files changed

+55
-43
lines changed

11 files changed

+55
-43
lines changed

content/version-control/branching-and-committing.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Illustration of what we want to achieve in this exercise.
4949
1. First create a new branch and then either add a new file or modify an
5050
existing file and commit the change. Make sure that you now work **on your
5151
copy** of the example repository. In your new commit you can share a Git or
52-
programming trick you like.
52+
programming trick you like or improve the documentation.
5353
1. In a new commit, modify the file again.
5454
1. Switch to the `main` branch and create a commit there.
5555
1. Browse the network and locate the commits that you just created ("Insights" -> "Network").
@@ -58,6 +58,16 @@ Illustration of what we want to achieve in this exercise.
5858
1. Try to rename the branch that you created and then browse the network again.
5959
1. Try to create a tag for one of the commits that you created (on GitHub,
6060
create a "release").
61+
1. Optional: If this was too easy, you can try to create a new branch and on
62+
this branch work on one of these new features:
63+
- The random seed is now set to a specific number (42). Make it possible to
64+
set the seed to another number or to turn off the seed setting via the command line interface.
65+
- Move the code that does the majority vote to an own function.
66+
- Write a test for the new majority vote function.
67+
- The `num_neighbors` in the code needs to be odd. Change the code so that it stops with an error message if an even number is given.
68+
- Add type annotations to some functions.
69+
- When calling the `scatter_plot` function, call the function with named arguments.
70+
- Add example usage to README.md.
6171
:::
6272

6373
The solution below goes over most of the answers, and you are
@@ -208,7 +218,7 @@ it makes sense later on.
208218
::::{group-tab} GitHub
209219
A nice way to compare branches is to add `/compare` to the URL of the repository,
210220
for example (replace USER):
211-
https://github.com/**USER**/planets/compare
221+
https://github.com/**USER**/classification-task/compare
212222
::::
213223

214224
::::{group-tab} VS Code
@@ -241,7 +251,7 @@ This is similar to above, but not only between branches.
241251
::::{group-tab} GitHub
242252
Following the `/compare`-trick above, one can compare commits on GitHub by
243253
adjusting the following URL:
244-
https://github.com/**USER**/planets/compare/**VERSION1**..**VERSION2**
254+
https://github.com/**USER**/classification-task/compare/**VERSION1**..**VERSION2**
245255

246256
Replace `USER` with your username and `VERSION1` and `VERSION2` with a commit hash or branch name.
247257
Please try it out.

content/version-control/browsing.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ It is also possible to do this: to clone a forked repository to your computer.
5555

5656
At all times you should be aware of if you are looking at **your repository**
5757
or the **upstream repository** (original repository):
58-
- Your repository: https://github.com/**USER**/planets
59-
- Upstream repository: https://github.com/**workshop-material**/planets
58+
- Your repository: https://github.com/**USER**/classification-task
59+
- Upstream repository: https://github.com/**workshop-material**/classification-task
6060

6161
:::{admonition} How to create a fork
62-
1. Go to the repository view on GitHub: <https://github.com/workshop-material/planets>
62+
1. Go to the repository view on GitHub: <https://github.com/workshop-material/classification-task>
6363
1. First, on GitHub, click the button that says "Fork". It is towards
6464
the top-right of the screen.
6565
1. You should shortly be redirected to your copy of the repository
66-
**USER/planets**.
66+
**USER/classification-task**.
6767
:::
6868

6969
:::{instructor-note}
@@ -95,7 +95,7 @@ Work on this by yourself or in pairs.
9595
In this case you will work on a fork.
9696

9797
You only need to open your own view, as described above. The browser
98-
URL should look like https://github.com/**USER**/planets, where
98+
URL should look like https://github.com/**USER**/classification-task, where
9999
USER is your GitHub username.
100100
::::
101101

@@ -110,7 +110,7 @@ locally.
110110
open), go to File → New Window.
111111
1. Under "Start" on the screen, select "Clone Git Repository...". Alternatively
112112
navigate to the "Source Control" tab on the left sidebar and click on the "Clone Repository" button.
113-
1. Paste in this URL: `https://github.com/USER/planets`, where
113+
1. Paste in this URL: `https://github.com/USER/classification-task`, where
114114
`USER` is your username. You can copy this from the browser.
115115
1. Browse and select the folder in which you want to clone the
116116
repository.
@@ -134,30 +134,30 @@ locally.
134134
(`cd ~/code` for example, if the `~/code` directory is where you
135135
store your files).
136136
1. Run the following command: `git clone
137-
https://github.com/USER/planets`, where `USER` is your
137+
https://github.com/USER/classification-task`, where `USER` is your
138138
username. You might need to use a SSH clone command instead of
139139
HTTPS, depending on your setup.
140-
1. Change to that directory: `cd planets`
140+
1. Change to that directory: `cd classification-task`
141141
::::
142142
:::::
143143
::::::
144144

145145

146146
:::{exercise} Exercise: Browsing an existing project (20 min)
147147

148-
Browse the [example project](https://github.com/workshop-material/planets) and
148+
Browse the [example project](https://github.com/workshop-material/classification-task) and
149149
explore commits and branches, either on a fork or on a clone. Take notes and
150150
prepare questions. The hints are for the GitHub path in the browser.
151151

152152
1. Browse the **commit history**: Are commit messages understandable?
153153
(Hint: "Commit history", the timeline symbol, above the file list)
154154
1. Compare the commit history with the **network graph** ("Insights" -> "Network"). Can you find the branches?
155-
1. Try to find the **history of commits for a single file**, e.g. `simulate.py`.
155+
1. Try to find the **history of commits for a single file**, e.g. `generate_predictions.py`.
156156
(Hint: "History" button in the file view)
157-
1. **Which files include the word "position"**?
157+
1. **Which files include the word "training"**?
158158
(Hint: the GitHub search on top of the repository view)
159-
1. In the `simulate.py` file,
160-
find out who modified the "time step"
159+
1. In the `generate_predictions.py` file,
160+
find out who modified the evaluation of "majority_index"
161161
last and **in which commit**.
162162
(Hint: "Blame" view in the file view)
163163
1. Can you use this code yourself? **Are you allowed to share
@@ -178,7 +178,7 @@ The most basic thing to look at is the history of commits.
178178

179179
* This is visible from a button in the repository view. We see every
180180
change, when, and who has committed.
181-
* Every change has a unique identifier, such as `244c993`. This can
181+
* Every change has a unique identifier, such as `79ce3be`. This can
182182
be used to identify both this change, and the whole project's
183183
version as of that change.
184184
* Clicking on a change in the view shows more.
@@ -263,12 +263,12 @@ for a single file.
263263
:::::{tabs}
264264

265265
::::{group-tab} GitHub
266-
Navigate to the file view: Main page → simulate.py.
266+
Navigate to the file view: Main page → generate_predictions.py.
267267
Click the "History" button near the top right.
268268
::::
269269

270270
::::{group-tab} VS Code
271-
Open simulate.py file in the editor. Under the file browser,
271+
Open generate_predictions.py file in the editor. Under the file browser,
272272
we see a "Timeline" view there.
273273
::::
274274

@@ -277,14 +277,14 @@ The `git log` command can take a filename and provide the log of only
277277
a single file:
278278

279279
```
280-
$ git log simulate.py
280+
$ git log generate_predictions.py
281281
```
282282
::::
283283

284284
:::::
285285

286286

287-
### (4) Which files include the word "position"?
287+
### (4) Which files include the word "training"?
288288

289289
Version control makes it very easy to find all occurrences of a
290290
word or pattern. This is useful for things like finding where functions or
@@ -293,7 +293,7 @@ variables are defined or used.
293293
:::::{tabs}
294294
::::{group-tab} GitHub
295295
We go to the main file view. We click the Search magnifying
296-
class at the very top, type "position", and click enter. We see every
296+
class at the very top, type "training", and click enter. We see every
297297
instance, including the context.
298298

299299
:::{admonition} Searching in a forked repository will not work instantaneously!
@@ -306,16 +306,16 @@ Start it, continue with other steps, then come back to this.
306306

307307
::::{group-tab} VS Code
308308
If you use the "Search" magnifying class on the left sidebar, and
309-
search for "position" it shows the occurrences in every file. You can
309+
search for "training" it shows the occurrences in every file. You can
310310
click to see the usage in context.
311311
::::
312312

313313
::::{group-tab} Command line
314314
`grep` is the command line tool that searches for lines matching a term
315315
```console
316-
$ git grep position # only the lines
317-
$ git grep -C 3 position # three lines of context
318-
$ git grep -i position # case insensitive
316+
$ git grep training # only the lines
317+
$ git grep -C 3 training # three lines of context
318+
$ git grep -i training # case insensitive
319319
```
320320
::::
321321

@@ -344,8 +344,8 @@ line version, after opening a terminal.
344344
::::{group-tab} Command line
345345
These two commands are similar but have slightly different output.
346346
```console
347-
$ git annotate simulate.py
348-
$ git blame simulate.py
347+
$ git annotate generate_predictions.py
348+
$ git blame generate_predictions.py
349349
```
350350
::::
351351

18.6 KB
Loading
13.9 KB
Loading
489 Bytes
Loading
223 Bytes
Loading

content/version-control/img/illustrations/drawing.svg

Lines changed: 7 additions & 7 deletions
Loading
730 Bytes
Loading

content/version-control/motivation.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ of them?):
3333

3434
## Demonstration
3535

36-
- Example repository: <https://github.com/workshop-material/planets>
36+
- Example repository: <https://github.com/workshop-material/classification-task>
3737
- Commits are like **snapshots** and if we break something we can go back to a
3838
previous snapshot.
3939
- Commits carry **metadata** about changes: author, date, commit message, and
4040
a checksum.
4141
- **Branches** are like parallel universes where you can experiment with
4242
changes without affecting the default branch:
43-
<https://github.com/workshop-material/planets/network>
43+
<https://github.com/workshop-material/classification-task/network>
4444
("Insights" -> "Network")
4545
- With version control we can **annotate code**
46-
([example](https://github.com/workshop-material/planets/blame/main/simulate.py)).
46+
([example](https://github.com/workshop-material/classification-tas/blame/main/generate_predictions.py)).
4747
- **Collaboration**: We can fork (make a copy on GitHub), clone (make a copy
4848
to our computer), review, compare, share, and discuss.
4949
- **Code review**: Others can suggest changes using pull requests or merge
@@ -70,15 +70,15 @@ Image created using <https://gopherize.me/>
7070

7171
- **Collaboration**: review, compare, share, discuss
7272

73-
- [Example network graph](https://github.com/workshop-material/planets/network)
73+
- [Example network graph](https://github.com/workshop-material/classification-task/network)
7474

7575

7676
## Talking about code
7777

7878
Which of these two is more practical?
79-
1. "Clone the code, go to the file 'simulate.py', and search for 'force_between_planets'.
80-
Oh! But make sure you use the version from September 2024."
81-
1. Or I can send you a permalink: <https://github.com/workshop-material/planets/blob/1343ac0/simulate.py#L31C5-L39>
79+
1. "Clone the code, go to the file 'generate_predictions.py', and search for 'majority_index'.
80+
Oh! But make sure you use the version from January 2025."
81+
1. Or I can send you a permalink: <https://github.com/workshop-material/classification-task/blob/79ce3be8/generate_predictions.py#L25-L28>
8282

8383

8484
## What we typically like to snapshot

content/version-control/practical-advice.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ this is based on a discussion in #123
2727
- **Why something was changed is more important than what has changed.**
2828
- Cross-reference to issues and discussions if possible/relevant.
2929
- Bad commit messages: "fix", "oops", "save work"
30-
- Bad examples: [http://whatthecommit.com](http://whatthecommit.com)
30+
- Just for fun, a page collecting bad examples: [http://whatthecommit.com](http://whatthecommit.com)
3131
- Write commit messages that will be understood
3232
15 years from now by someone else than you. Or by your future you.
3333
- Many projects start out as projects "just for me" and end up to be successful projects

0 commit comments

Comments
 (0)