Skip to content

Commit 526760b

Browse files
committed
fix tags errors
1 parent 1869ac4 commit 526760b

11 files changed

+80
-113
lines changed

lectures/debugging.md

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ import matplotlib.pyplot as plt
5858
Let's consider a simple (and rather contrived) example
5959

6060
```{code-cell} ipython
61-
---
62-
tags: [raises-exception]
63-
---
61+
:tags: raises-exception
62+
6463
def plot_log():
6564
fig, ax = plt.subplots(2, 1)
6665
x = np.linspace(1, 2, 10)
@@ -85,9 +84,8 @@ But let's pretend that we don't understand this for the moment.
8584
We might suspect there's something wrong with `ax` but when we try to investigate this object, we get the following exception:
8685

8786
```{code-cell} python3
88-
---
89-
tags: [raises-exception]
90-
---
87+
:tags: raises-exception
88+
9189
ax
9290
```
9391

@@ -99,9 +97,8 @@ Let's try doing it a different way.
9997
We run the first cell block again, generating the same error
10098

10199
```{code-cell} python3
102-
---
103-
tags: [raises-exception]
104-
---
100+
:tags: raises-exception
101+
105102
def plot_log():
106103
fig, ax = plt.subplots(2, 1)
107104
x = np.linspace(1, 2, 10)
@@ -178,9 +175,8 @@ The preceding approach is handy but sometimes insufficient.
178175
Consider the following modified version of our function above
179176

180177
```{code-cell} python3
181-
---
182-
tags: [raises-exception]
183-
---
178+
:tags: raises-exception
179+
184180
def plot_log():
185181
fig, ax = plt.subplots()
186182
x = np.logspace(1, 2, 10)
@@ -283,7 +279,7 @@ In this section, we'll discuss different types of errors in Python and technique
283279

284280
### Errors in Python
285281

286-
We have seen `AttributeError` and `NameError` in {any}`our previous examples <debug_magic>`.
282+
We have seen `AttributeError` and `NameError` in [our previous examples](#debug_magic).
287283

288284
In Python, there are two types of errors -- syntax errors and exceptions.
289285

@@ -293,9 +289,8 @@ In Python, there are two types of errors -- syntax errors and exceptions.
293289
Here's an example of a common error type
294290

295291
```{code-cell} python3
296-
---
297-
tags: [raises-exception]
298-
---
292+
:tags: raises-exception
293+
299294
def f:
300295
```
301296

@@ -304,36 +299,32 @@ Since illegal syntax cannot be executed, a syntax error terminates execution of
304299
Here's a different kind of error, unrelated to syntax
305300

306301
```{code-cell} python3
307-
---
308-
tags: [raises-exception]
309-
---
302+
:tags: raises-exception
303+
310304
1 / 0
311305
```
312306

313307
Here's another
314308

315309
```{code-cell} python3
316-
---
317-
tags: [raises-exception]
318-
---
310+
:tags: raises-exception
311+
319312
x1 = y1
320313
```
321314

322315
And another
323316

324317
```{code-cell} python3
325-
---
326-
tags: [raises-exception]
327-
---
318+
:tags: raises-exception
319+
328320
'foo' + 6
329321
```
330322

331323
And another
332324

333325
```{code-cell} python3
334-
---
335-
tags: [raises-exception]
336-
---
326+
:tags: raises-exception
327+
337328
X = []
338329
x = X[0]
339330
```
@@ -367,9 +358,8 @@ If we run this with an array of length one, the program will terminate and
367358
print our error message
368359

369360
```{code-cell} python3
370-
---
371-
tags: [raises-exception]
372-
---
361+
:tags: raises-exception
362+
373363
var([1])
374364
```
375365

@@ -499,7 +489,7 @@ prices
499489

500490
Using `try` -- `except`, write a program to read in the contents of the file and sum the numbers, ignoring lines without numbers.
501491

502-
You can use the `open()` function we learnt {any}`before<iterators>` to open `numbers.txt`.
492+
You can use the `open()` function we learnt [before](#iterators) to open `numbers.txt`.
503493
```{exercise-end}
504494
```
505495

lectures/functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Functions without a return statement automatically return the special Python obj
161161
```{index} single: Python; keyword arguments
162162
```
163163

164-
In a {ref}`previous lecture <python_by_example>`, you came across the statement
164+
In a [previous lecture](python_by_example.md), you came across the statement
165165

166166
```{code-block} python3
167167
:class: no-execute
@@ -203,7 +203,7 @@ f(2, a=4, b=5)
203203

204204
### The Flexibility of Python Functions
205205

206-
As we discussed in the {ref}`previous lecture <python_by_example>`, Python functions are very flexible.
206+
As we discussed in the [previous lecture](python_by_example.md), Python functions are very flexible.
207207

208208
In particular
209209

lectures/matplotlib.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,9 @@ If you are interested, you can even create your own style sheets.
343343
Parameters for your style sheets are stored in a dictionary-like variable `plt.rcParams`
344344

345345
```{code-cell} python3
346-
---
347-
tags: [hide-output]
348-
---
346+
:tags: hide-output
349347
350348
print(plt.rcParams.keys())
351-
352349
```
353350

354351
There are many parameters you could set for your style sheets.

lectures/myst.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ project:
7474
error_rules:
7575
- rule: reference-syntax-valid
7676
severity: ignore
77-
exports:
78-
- id: book-pdf
79-
format: typst
80-
template: https://github.com/rowanc1/typst-book.git
81-
output: exports/quantecon-python-intro.pdf
82-
downloads:
83-
- id: book-pdf
84-
title: Book (PDF)
77+
# exports:
78+
# - id: book-pdf
79+
# format: typst
80+
# template: https://github.com/rowanc1/typst-book.git
81+
# output: exports/quantecon-lecture-python.pdf
82+
# downloads:
83+
# - id: book-pdf
84+
# title: Book (PDF)
8585
site:
8686
parts:
8787
footer: footer.md

lectures/need_for_speed.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ We'll also discuss the following topics:
4141
In addition to what's in Anaconda, this lecture will need
4242

4343
```{code-cell} ipython
44-
---
45-
tags: [hide-output]
46-
---
44+
:tags: hide-output
45+
4746
!pip install quantecon
4847
```
4948

lectures/numpy.md

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,8 @@ a + b
514514
Here is a visual representation of this broadcasting operation:
515515

516516
```{code-cell} python3
517-
---
518-
tags: [hide-input]
519-
---
517+
:tags: hide-input
518+
520519
# Adapted and modified based on the code in the book written by Jake VanderPlas (see https://jakevdp.github.io/PythonDataScienceHandbook/06.00-figure-code.html#Broadcasting)
521520
# Originally from astroML: see http://www.astroml.org/book_figures/appendix/fig_broadcast_visual.html
522521
@@ -643,9 +642,8 @@ a + b
643642
Here is a visual representation of this broadcasting operation:
644643

645644
```{code-cell} python3
646-
---
647-
tags: [hide-input]
648-
---
645+
:tags: hide-input
646+
649647
650648
fig = plt.figure(figsize=(5, 1), facecolor='w')
651649
ax = plt.axes([0, 0, 1, 1], xticks=[], yticks=[], frameon=False)
@@ -725,9 +723,8 @@ a + b
725723
Here is a visual representation of this broadcasting operation:
726724

727725
```{code-cell} python3
728-
---
729-
tags: [hide-input]
730-
---
726+
:tags: hide-input
727+
731728
732729
# Draw a figure and axis with no boundary
733730
fig = plt.figure(figsize=(5, 1), facecolor='w')
@@ -781,9 +778,8 @@ While broadcasting is very useful, it can sometimes seem confusing.
781778
For example, let's try adding `a -> (3, 2)` and `b -> (3,)`.
782779

783780
```{code-cell} python3
784-
---
785-
tags: [raises-exception]
786-
---
781+
:tags: raises-exception
782+
787783
a = np.array(
788784
[[1, 2],
789785
[4, 5],
@@ -799,9 +795,8 @@ The `ValueError` tells us that operands could not be broadcast together.
799795
Here is a visual representation to show why this broadcasting cannot be executed:
800796

801797
```{code-cell} python3
802-
---
803-
tags: [hide-input]
804-
---
798+
:tags: hide-input
799+
805800
# Draw a figure and axis with no boundary
806801
fig = plt.figure(figsize=(3, 1.3), facecolor='w')
807802
ax = plt.axes([0, 0, 1, 1], xticks=[], yticks=[], frameon=False)
@@ -901,9 +896,8 @@ a + b
901896
- We can see that they do not match each other after the first two steps. Thus, a `ValueError` will be raised
902897

903898
```{code-cell} python3
904-
---
905-
tags: [raises-exception]
906-
---
899+
:tags: raises-exception
900+
907901
a = np.array(
908902
[[[1, 2, 3],
909903
[2, 3, 4]],
@@ -1595,9 +1589,8 @@ A = x / y
15951589
Here is the output
15961590

15971591
```{code-cell} python3
1598-
---
1599-
tags: [hide-output]
1600-
---
1592+
:tags: hide-output
1593+
16011594
print(A)
16021595
```
16031596

@@ -1608,7 +1601,8 @@ For this part of the exercise you can use the `tic`/`toc` functions from the `qu
16081601
Let's make sure this library is installed.
16091602

16101603
```{code-cell} python3
1611-
:tags: [hide-output]
1604+
:tags: hide-output
1605+
16121606
!pip install quantecon
16131607
```
16141608

@@ -1628,9 +1622,8 @@ qe.toc()
16281622
Here is the output
16291623

16301624
```{code-cell} python3
1631-
---
1632-
tags: [hide-output]
1633-
---
1625+
:tags: hide-output
1626+
16341627
print(B)
16351628
```
16361629

@@ -1659,9 +1652,8 @@ for i in range(n):
16591652
Compare the results to check your answer
16601653

16611654
```{code-cell} python3
1662-
---
1663-
tags: [hide-output]
1664-
---
1655+
:tags: hide-output
1656+
16651657
print(C)
16661658
```
16671659

@@ -1695,9 +1687,8 @@ Note that the `for` loop takes much longer than the broadcasting operation.
16951687
Compare the results to check your answer
16961688

16971689
```{code-cell} python3
1698-
---
1699-
tags: [hide-output]
1700-
---
1690+
:tags: hide-output
1691+
17011692
print(D)
17021693
```
17031694

lectures/oop_intro.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,8 @@ On the other hand, between two numbers it means ordinary addition
107107
Consider the following expression
108108

109109
```{code-cell} python3
110-
---
111-
tags: [raises-exception]
112-
---
110+
:tags: raises-exception
111+
113112
'300' + 400
114113
```
115114

@@ -342,7 +341,7 @@ and write clear Pythonic code.
342341
:label: oop_intro_ex1
343342
```
344343

345-
We have met the {any}`boolean data type <boolean>` previously.
344+
We have met the [boolean data type](python_essentials.md#boolean) previously.
346345

347346
Using what we have learnt in this lecture, print a list of methods of the
348347
boolean object `True`.

lectures/parallelization.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ kernelspec:
1515
In addition to what's in Anaconda, this lecture will need the following libraries:
1616

1717
```{code-cell} ipython
18-
---
19-
tags: [hide-output]
20-
---
18+
:tags: hide-output
19+
2120
!pip install quantecon
2221
```
2322

@@ -177,7 +176,7 @@ To get some basis for comparison for the last example, let's try the same
177176
thing with Numba.
178177

179178
In fact there is an easy way to do this, since Numba can also be used to
180-
create custom {ref}`ufuncs <ufuncs>` with the [@vectorize](http://numba.pydata.org/numba-doc/dev/user/vectorize.html) decorator.
179+
create custom {ref}`ufuncs <ufuncs>` with the [`@vectorize`](http://numba.pydata.org/numba-doc/dev/user/vectorize.html) decorator.
181180

182181
```{code-cell} python3
183182
from numba import vectorize

0 commit comments

Comments
 (0)