Skip to content

Commit 50a76b6

Browse files
Copilotmmcky
andcommitted
Convert all %timeit instances to qe.timeit() with runs=3
Co-authored-by: mmcky <[email protected]>
1 parent 03a37af commit 50a76b6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lectures/parallelization.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ x, y = np.meshgrid(grid, grid)
166166
```
167167

168168
```{code-cell} ipython3
169-
%timeit np.max(f(x, y))
169+
qe.timeit(lambda: np.max(f(x, y)), runs=3)
170170
```
171171

172172
If you have a system monitor such as htop (Linux/Mac) or perfmon
@@ -198,7 +198,7 @@ np.max(f_vec(x, y)) # Run once to compile
198198
```
199199

200200
```{code-cell} ipython3
201-
%timeit np.max(f_vec(x, y))
201+
qe.timeit(lambda: np.max(f_vec(x, y)), runs=3)
202202
```
203203

204204
At least on our machine, the difference in the speed between the
@@ -248,7 +248,7 @@ np.max(f_vec(x, y)) # Run once to compile
248248
```
249249

250250
```{code-cell} ipython3
251-
%timeit np.max(f_vec(x, y))
251+
qe.timeit(lambda: np.max(f_vec(x, y)), runs=3)
252252
```
253253

254254
Now our code runs significantly faster than the NumPy version.

lectures/scipy.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ However, it's more common and better practice to use NumPy functionality explici
6464

6565
```{code-cell} python3
6666
import numpy as np
67+
import quantecon as qe
6768
6869
a = np.identity(3)
6970
```
@@ -320,11 +321,11 @@ brentq(f, 0, 1)
320321
Here the correct solution is found and the speed is better than bisection:
321322

322323
```{code-cell} ipython
323-
%timeit brentq(f, 0, 1)
324+
qe.timeit(lambda: brentq(f, 0, 1), runs=3)
324325
```
325326

326327
```{code-cell} ipython
327-
%timeit bisect(f, 0, 1)
328+
qe.timeit(lambda: bisect(f, 0, 1), runs=3)
328329
```
329330

330331
### Multivariate Root-Finding

0 commit comments

Comments
 (0)