Skip to content

Commit 05d256a

Browse files
committed
n-body & leases: use courselevels to outline student cells for easier correction
1 parent 349796e commit 05d256a

6 files changed

Lines changed: 102 additions & 4 deletions

File tree

notebooks/numpy-tps/n-body/.teacher/README-n-body-corrige-nb.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ speed_max = 1.
6969
```
7070

7171
```{code-cell} ipython3
72+
:tags: [level_basic]
73+
7274
# votre code
7375
7476
def init_problem(N):
@@ -100,6 +102,8 @@ def init_problem(N):
100102
```
101103

102104
```{code-cell} ipython3
105+
:tags: [level_intermediate]
106+
103107
# pour tester
104108
105109
# normalement vous devez pouvoir faire ceci
@@ -151,6 +155,8 @@ $$
151155
pour cela on se propose d'écrire la fonction suivante
152156

153157
```{code-cell} ipython3
158+
:tags: [level_basic]
159+
154160
# votre code
155161
156162
def forces(masses, positions, G=1.0):
@@ -187,6 +193,8 @@ def forces(masses, positions, G=1.0):
187193
```
188194

189195
```{code-cell} ipython3
196+
:tags: [level_intermediate]
197+
190198
# pour tester, voici les valeurs attendues avec la config prédéfinie
191199
192200
masses, positions, speeds = init3()
@@ -206,6 +214,8 @@ f = forces(masses, positions)
206214
cela pourrait se passer dans une fonction qui ressemblerait à ceci
207215

208216
```{code-cell} ipython3
217+
:tags: [level_basic]
218+
209219
# votre code
210220
211221
def simulate(masses, positions, speeds, dt=0.1, nb_steps=100):
@@ -245,6 +255,8 @@ def simulate(masses, positions, speeds, dt=0.1, nb_steps=100):
245255
```
246256

247257
```{code-cell} ipython3
258+
:tags: [level_intermediate]
259+
248260
# pour tester
249261
250262
SMALL_STEPS = 4
@@ -259,6 +271,8 @@ except Exception as exc:
259271
```
260272

261273
```{code-cell} ipython3
274+
:tags: [level_intermediate]
275+
262276
# pour tester: should be true
263277
264278
# first step
@@ -284,6 +298,8 @@ si j'avais voulu implémenter 2.b il faudrait tripoter un peu plus nos interface
284298
```
285299

286300
```{code-cell} ipython3
301+
:tags: [level_basic]
302+
287303
# votre code
288304
289305
def draw(simulation, masses, colors=None, scale=10.):
@@ -354,6 +370,8 @@ colors3 = np.array([
354370
pour commencer et tester, on se met dans l'état initial reproductible
355371

356372
```{code-cell} ipython3
373+
:tags: [level_intermediate]
374+
357375
# décommentez ceci pour tester votre code
358376
359377
# masses, positions, speeds = init3()
76 Bytes
Binary file not shown.

notebooks/numpy-tps/n-body/README-n-body-nb.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ speed_max = 1.
6969
```
7070

7171
```{code-cell} ipython3
72+
:tags: [level_basic]
73+
7274
# votre code
7375
7476
def init_problem(N):
@@ -81,6 +83,8 @@ def init_problem(N):
8183
```
8284

8385
```{code-cell} ipython3
86+
:tags: [level_intermediate]
87+
8488
# pour tester
8589
8690
# normalement vous devez pouvoir faire ceci
@@ -132,6 +136,8 @@ $$
132136
pour cela on se propose d'écrire la fonction suivante
133137

134138
```{code-cell} ipython3
139+
:tags: [level_basic]
140+
135141
# votre code
136142
137143
def forces(masses, positions, G=1.0):
@@ -145,6 +151,8 @@ def forces(masses, positions, G=1.0):
145151
```
146152

147153
```{code-cell} ipython3
154+
:tags: [level_intermediate]
155+
148156
# pour tester, voici les valeurs attendues avec la config prédéfinie
149157
150158
masses, positions, speeds = init3()
@@ -164,6 +172,8 @@ f = forces(masses, positions)
164172
cela pourrait se passer dans une fonction qui ressemblerait à ceci
165173

166174
```{code-cell} ipython3
175+
:tags: [level_basic]
176+
167177
# votre code
168178
169179
def simulate(masses, positions, speeds, dt=0.1, nb_steps=100):
@@ -176,6 +186,8 @@ def simulate(masses, positions, speeds, dt=0.1, nb_steps=100):
176186
```
177187

178188
```{code-cell} ipython3
189+
:tags: [level_intermediate]
190+
179191
# pour tester
180192
181193
SMALL_STEPS = 4
@@ -190,6 +202,8 @@ except Exception as exc:
190202
```
191203

192204
```{code-cell} ipython3
205+
:tags: [level_intermediate]
206+
193207
# pour tester: should be true
194208
195209
# first step
@@ -215,6 +229,8 @@ si j'avais voulu implémenter 2.b il faudrait tripoter un peu plus nos interface
215229
```
216230

217231
```{code-cell} ipython3
232+
:tags: [level_basic]
233+
218234
# votre code
219235
220236
def draw(simulation, masses, colors=None, scale=10.):
@@ -249,6 +265,8 @@ colors3 = np.array([
249265
pour commencer et tester, on se met dans l'état initial reproductible
250266

251267
```{code-cell} ipython3
268+
:tags: [level_intermediate]
269+
252270
# décommentez ceci pour tester votre code
253271
254272
# masses, positions, speeds = init3()

notebooks/pandas-tps/leases/.teacher/README-leases-corrige-nb.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ here's an example of the outputs we will obtain
4848
## imports
4949

5050
```{code-cell} ipython3
51-
5251
import pandas as pd
5352
import matplotlib.pyplot as plt
5453
```
5554

5655
1. make sure to use matplotlib in interactive mode - aka `ipympl`
5756

5857
```{code-cell} ipython3
58+
:tags: [level_basic]
59+
5960
# your code
6061
```
6162

@@ -69,6 +70,8 @@ import matplotlib.pyplot as plt
6970
2. optional: setup itables, so that we can have scrollable tables
7071

7172
```{code-cell} ipython3
73+
:tags: [level_basic]
74+
7275
# your code
7376
```
7477

@@ -93,6 +96,8 @@ leases.head(10)
9396
surely the columns dtypes need some care
9497

9598
```{code-cell} ipython3
99+
:tags: [level_basic]
100+
96101
# your code
97102
```
98103

@@ -106,6 +111,8 @@ leases['end'] = pd.to_datetime(leases['end'], format="ISO8601")
106111
```
107112

108113
```{code-cell} ipython3
114+
:tags: [level_intermediate]
115+
109116
# check it
110117
111118
leases.dtypes
@@ -116,6 +123,8 @@ leases.dtypes
116123
check that the data is well-formed, i.e. **the `end`** timestamp **happens after `beg`**
117124

118125
```{code-cell} ipython3
126+
:tags: [level_basic]
127+
119128
# your code
120129
```
121130

@@ -138,6 +147,8 @@ nothing in the rest depends on this question, so if you find this too hard, you
138147
```
139148

140149
```{code-cell} ipython3
150+
:tags: [level_basic]
151+
141152
# your code
142153
```
143154

@@ -194,6 +205,8 @@ diff.tail(3)
194205
What is the timespan covered by the dataset (**earliest** and **latest** events, and **duration** in-between) ?
195206

196207
```{code-cell} ipython3
208+
:tags: [level_basic]
209+
197210
# your code
198211
```
199212

@@ -217,6 +230,8 @@ so, given that there is no overlap, we can assume this corresponds to "reservati
217230
write a code that computes the **overall reservation time**, as well as the **average usage ratio** over the overall timespan
218231

219232
```{code-cell} ipython3
233+
:tags: [level_basic]
234+
220235
# your code
221236
```
222237

@@ -260,8 +275,9 @@ you should produce something like e.g.
260275
we'll make cosmetic improvements below, and [the final results look like this](#label-leases-output), but let's not get ahead of ourselves
261276
`````
262277

263-
264278
```{code-cell} ipython3
279+
:tags: [level_basic]
280+
265281
# your code
266282
```
267283

@@ -357,6 +373,8 @@ SPACES = {
357373
```
358374

359375
```{code-cell} ipython3
376+
:tags: [level_basic]
377+
360378
# your code
361379
```
362380

@@ -391,6 +409,7 @@ you are to write a function that converts a `pd.Timedelta` into a number of hour
391409
2. use it to test your own implementation
392410

393411
```{code-cell} ipython3
412+
:tags: [level_basic]
394413
395414
# your code
396415
@@ -399,7 +418,6 @@ def convert_timedelta_to_hours(timedelta: pd.Timedelta) -> int:
399418
```
400419

401420
```{code-cell} ipython3
402-
403421
# prune-cell
404422
405423
import numpy as np
@@ -410,6 +428,8 @@ def convert_timedelta_to_hours(timedelta):
410428
```
411429

412430
```{code-cell} ipython3
431+
:tags: [level_intermediate]
432+
413433
# test it
414434
415435
# if an hour has started even by one second, it is counted
@@ -441,6 +461,7 @@ test_convert_timedelta_to_hours()
441461
```
442462

443463
```{code-cell} ipython3
464+
:tags: [level_intermediate]
444465
445466
# for debugging; this should return 48
446467
@@ -453,6 +474,8 @@ keep the same visu, but display **the Y axis in hours**
453474
btw, what was the unit in the graphs above ?
454475

455476
```{code-cell} ipython3
477+
:tags: [level_basic]
478+
456479
# your code
457480
```
458481

@@ -491,6 +514,8 @@ countries.head(3)
491514
what's the most effective way to see how many regions and how many countries per region ?
492515

493516
```{code-cell} ipython3
517+
:tags: [level_basic]
518+
494519
# your code
495520
```
496521

@@ -511,6 +536,8 @@ your mission is to now show the same graphs, but we want to reflect the relative
511536
most likely your first move is to tag all leases with a `region` column
512537

513538
```{code-cell} ipython3
539+
:tags: [level_basic]
540+
514541
# your code
515542
```
516543

@@ -525,12 +552,13 @@ leases2.drop(columns=['name'], inplace=True)
525552
leases2
526553
```
527554

528-
529555
### visu by period by region
530556

531557
you can now produce [the target figures, again they look like this](#label-leases-output)
532558

533559
```{code-cell} ipython3
560+
:tags: [level_basic]
561+
534562
# your code
535563
```
536564

10 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)