Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5e2cbcf

Browse filesBrowse files
authored
update admonitions (#233)
1 parent d6a1e53 commit 5e2cbcf
Copy full SHA for 5e2cbcf

File tree

Expand file treeCollapse file tree

6 files changed

+57
-20
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+57
-20
lines changed
Open diff view settings
Collapse file

‎lectures/functions.md‎

Copy file name to clipboardExpand all lines: lectures/functions.md
+11-4Lines changed: 11 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ Try to use lambda expressions to define the function `f`.
513513
:class: dropdown
514514
```
515515

516-
- Here's one solution for part 1
516+
Here's one solution for part 1
517517

518518
```{code-cell} python3
519519
def factorial(n):
@@ -525,7 +525,7 @@ def factorial(n):
525525
factorial(4)
526526
```
527527

528-
- Adding the lambda expression
528+
Adding the lambda expression
529529

530530
```{code-cell} python3
531531
def factorial(n,f = lambda x: x):
@@ -561,14 +561,21 @@ The [binomial random variable](https://en.wikipedia.org/wiki/Binomial_distributi
561561
Without any import besides `from numpy.random import uniform`, write a function
562562
`binomial_rv` such that `binomial_rv(n, p)` generates one draw of $Y$.
563563

564-
Hint: If $U$ is uniform on $(0, 1)$ and $p \in (0,1)$, then the expression `U < p` evaluates to `True` with probability $p$.
564+
```{hint}
565+
:class: dropdown
566+
567+
If $U$ is uniform on $(0, 1)$ and $p \in (0,1)$, then the expression `U < p` evaluates to `True` with probability $p$.
568+
```
569+
565570
```{exercise-end}
566571
```
567572

568573

569574
```{solution-start} func_ex2
570575
:class: dropdown
571-
````
576+
```
577+
578+
Here is one solution:
572579

573580
```{code-cell} python3
574581
from numpy.random import uniform
Collapse file

‎lectures/getting_started.md‎

Copy file name to clipboardExpand all lines: lectures/getting_started.md
+3-1Lines changed: 3 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ When you're ready to execute the code in a cell, hit `Shift-Enter` instead of th
247247
:figclass: auto
248248
```
249249

250-
(Note: There are also menu and button options for running code in a cell that you can find by exploring)
250+
```{note}
251+
There are also menu and button options for running code in a cell that you can find by exploring.
252+
```
251253

252254
#### Modal Editing
253255

Collapse file

‎lectures/numba.md‎

Copy file name to clipboardExpand all lines: lectures/numba.md
+6-2Lines changed: 6 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ When Numba compiles machine code for functions, it treats global variables as co
478478
```{exercise}
479479
:label: speed_ex1
480480
481-
{ref}`Previously <pbe_ex3>` we considered how to approximate $\pi$ by
481+
{ref}`Previously <pbe_ex5>` we considered how to approximate $\pi$ by
482482
Monte Carlo.
483483
484484
Use the same idea here, but make the code efficient using Numba.
@@ -560,11 +560,15 @@ To test your code, evaluate the fraction of time that the chain spends in the lo
560560

561561
If your code is correct, it should be about 2/3.
562562

563-
Hints:
563+
564+
```{hint}
565+
:class: dropdown
564566
565567
* Represent the low state as 0 and the high state as 1.
566568
* If you want to store integers in a NumPy array and then apply JIT compilation, use `x = np.empty(n, dtype=np.int_)`.
567569
570+
```
571+
568572
```{exercise-end}
569573
```
570574

Collapse file

‎lectures/numpy.md‎

Copy file name to clipboardExpand all lines: lectures/numpy.md
+10-3Lines changed: 10 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1189,8 +1189,10 @@ Now write a new function that does the same job, but uses NumPy arrays and array
11891189

11901190
(Such functionality is already implemented as `np.poly1d`, but for the sake of the exercise don't use this class)
11911191

1192-
* Hint: Use `np.cumprod()`
1193-
1192+
```{hint}
1193+
:class: dropdown
1194+
Use `np.cumprod()`
1195+
```
11941196
```{exercise-end}
11951197
```
11961198

@@ -1262,7 +1264,12 @@ It helps to sketch the intervals on paper.
12621264

12631265
Your exercise is to speed it up using NumPy, avoiding explicit loops
12641266

1265-
* Hint: Use `np.searchsorted` and `np.cumsum`
1267+
```{hint}
1268+
:class: dropdown
1269+
1270+
Use `np.searchsorted` and `np.cumsum`
1271+
1272+
```
12661273

12671274
If you can, implement the functionality as a class called `DiscreteRV`, where
12681275

Collapse file

‎lectures/pandas.md‎

Copy file name to clipboardExpand all lines: lectures/pandas.md
+3-1Lines changed: 3 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,12 @@ A trivial example is to return itself for each row in the dataframe
321321
df.apply(lambda row: row, axis=1)
322322
```
323323

324-
Note: for the `.apply()` method
324+
```{note}
325+
For the `.apply()` method
325326
- axis = 0 -- apply function to each column (variables)
326327
- axis = 1 -- apply function to each row (observations)
327328
- axis = 0 is the default parameter
329+
```
328330

329331
We can use it together with `.loc[]` to do some more advanced selection.
330332

Collapse file

‎lectures/python_essentials.md‎

Copy file name to clipboardExpand all lines: lectures/python_essentials.md
+24-9Lines changed: 24 additions & 9 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,10 @@ all([1 <= 2 <= 3, "a" in "letter"])
595595
any([1 <= 2 <= 3, "a" in "letter"])
596596
```
597597

598-
Note:
599-
598+
```{note}
600599
* `all()` returns `True` when *all* boolean values/expressions in the sequence are `True`
601600
* `any()` returns `True` when *any* boolean values/expressions in the sequence are `True`
602-
601+
```
603602

604603
## Coding Style and Documentation
605604

@@ -692,20 +691,28 @@ Solve the following exercises.
692691

693692
(For some, the built-in function `sum()` comes in handy).
694693

695-
```{exercise}
694+
```{exercise-start}
696695
:label: pyess_ex1
697-
696+
```
698697
Part 1: Given two numeric lists or tuples `x_vals` and `y_vals` of equal length, compute
699698
their inner product using `zip()`.
700699

701700
Part 2: In one line, count the number of even numbers in 0,...,99.
702701

703-
* Hint: `x % 2` returns 0 if `x` is even, 1 otherwise.
704-
705702
Part 3: Given `pairs = ((2, 5), (4, 2), (9, 8), (12, 10))`, count the number of pairs `(a, b)`
706703
such that both `a` and `b` are even.
704+
705+
```{hint}
706+
:class: dropdown
707+
708+
`x % 2` returns 0 if `x` is even, 1 otherwise.
709+
707710
```
708711

712+
```{exercise-end}
713+
```
714+
715+
709716
```{solution-start} pyess_ex1
710717
:class: dropdown
711718
```
@@ -804,12 +811,20 @@ p(1, (2, 4))
804811
```
805812

806813

807-
```{exercise}
814+
```{exercise-start}
808815
:label: pyess_ex3
816+
```
809817

810818
Write a function that takes a string as an argument and returns the number of capital letters in the string.
811819

812-
Hint: `'foo'.upper()` returns `'FOO'`.
820+
```{hint}
821+
:class: dropdown
822+
823+
`'foo'.upper()` returns `'FOO'`.
824+
825+
```
826+
827+
```{exercise-end}
813828
```
814829

815830
```{solution-start} pyess_ex3

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.