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 1a85bf9

Browse filesBrowse files
committed
add update for PR #52 on sphinxcontrib-tomyst
1 parent a794344 commit 1a85bf9
Copy full SHA for 1a85bf9
Expand file treeCollapse file tree

13 files changed

+54
-54
lines changed
Open diff view settings
Collapse file

‎source/rst/functions.md‎

Copy file name to clipboardExpand all lines: source/rst/functions.md
+3-3Lines changed: 3 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ If the built-in functions don't cover what we need, we either need to import
8888
functions or create our own.
8989

9090
Examples of importing and using functions
91-
were given in the previous lecture
91+
were given in the {doc}`previous lecture <python_by_example>`
9292

9393
Here's another one, which tests whether a given year is a leap year:
9494

@@ -168,13 +168,13 @@ User-defined functions are important for improving the clarity of your code by
168168

169169
(Writing the same thing twice is [almost always a bad idea](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself))
170170

171-
We will say more about this later.
171+
We will say more about this {doc}`later <writing_good_code>`.
172172

173173
## Applications
174174

175175
### Random Draws
176176

177-
Consider again this code from the previous lecture
177+
Consider again this code from the {doc}`previous lecture <python_by_example>`
178178

179179
```{code-block} python3
180180
ts_length = 100
Collapse file

‎source/rst/need_for_speed.md‎

Copy file name to clipboardExpand all lines: source/rst/need_for_speed.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -459,5 +459,5 @@ with vectorization listed above.
459459
It does so through something called **just in time (JIT) compilation**,
460460
which can generate extremely fast and efficient code.
461461

462-
We'll learn how to use Numba soon.
462+
We'll learn how to use Numba {doc}`soon <numba>`.
463463

Collapse file

‎source/rst/numba.md‎

Copy file name to clipboardExpand all lines: source/rst/numba.md
+8-8Lines changed: 8 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
1919
```
2020

2121
Please also make sure that you have the latest version of Anaconda, since old
22-
versions are a common source of errors.
22+
versions are a {doc}`common source of errors <troubleshooting>`.
2323

2424
Let's start with some imports:
2525

@@ -33,12 +33,12 @@ import matplotlib.pyplot as plt
3333

3434
## Overview
3535

36-
In an earlier lecture we learned about vectorization, which is one method to improve speed and efficiency in numerical work.
36+
In an {doc}`earlier lecture <need_for_speed>` we learned about vectorization, which is one method to improve speed and efficiency in numerical work.
3737

3838
Vectorization involves sending array processing
3939
operations in batch to efficient low-level code.
4040

41-
However, as discussed previously, vectorization has several weaknesses.
41+
However, as {doc}`discussed previously <numba-p_c_vectorization>`, vectorization has several weaknesses.
4242

4343
One is that it is highly memory-intensive when working with large amounts of data.
4444

@@ -157,7 +157,7 @@ Numba attempts to generate fast machine code using the infrastructure provided b
157157

158158
It does this by inferring type information on the fly.
159159

160-
(See our earlier lecture on scientific computing for a discussion of types.)
160+
(See our {doc}`earlier lecture <need_for_speed>` on scientific computing for a discussion of types.)
161161

162162
The basic idea is this:
163163

@@ -187,7 +187,7 @@ qm_numba = jit(qm)
187187

188188
In practice this would typically be done using an alternative *decorator* syntax.
189189

190-
(We will explain all about decorators in a later lecture but you can skip the details at this stage.)
190+
(We will explain all about decorators in a {doc}`later lecture <python_advanced_features>` but you can skip the details at this stage.)
191191

192192
Let's see how this is done.
193193

@@ -264,7 +264,7 @@ If a class is successfully compiled, then its methods act as JIT-compiled
264264
functions.
265265

266266
To give one example, let's consider the class for analyzing the Solow growth model we
267-
created in this lecture.
267+
created in {doc}`this lecture <python_oop>`.
268268

269269
To compile this class we use the `@jitclass` decorator:
270270

@@ -379,7 +379,7 @@ If you prefer, you can safely skip this section.
379379

380380
### Cython
381381

382-
Like Numba, [Cython](http://cython.org/) provides an approach to generating fast compiled code that can be used from Python.
382+
Like {doc}`Numba <numba>`, [Cython](http://cython.org/) provides an approach to generating fast compiled code that can be used from Python.
383383

384384
As was the case with Numba, a key problem is the fact that Python is dynamically typed.
385385

@@ -461,7 +461,7 @@ When Numba compiles machine code for functions, it treats global variables as co
461461

462462
### Exercise 1
463463

464-
Previously we considered how to approximate $\pi$ by
464+
{doc}`Previously <pbe_ex3>` we considered how to approximate $\pi$ by
465465
Monte Carlo.
466466

467467
Use the same idea here, but make the code efficient using Numba.
Collapse file

‎source/rst/numpy.md‎

Copy file name to clipboardExpand all lines: source/rst/numpy.md
+4-4Lines changed: 4 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ a
503503
What's happened is that we have changed `a` by changing `b`.
504504

505505
The name `b` is bound to `a` and becomes just another reference to the
506-
array (the Python assignment model is described in more detail later in the course).
506+
array (the Python assignment model is described in more detail {doc}`later in the course <python_advanced_features>`).
507507

508508
Hence, it has equal rights to make changes to that array.
509509

@@ -700,7 +700,7 @@ single: Python; SciPy
700700

701701
Much of this functionality is also available in [SciPy](http://www.scipy.org/), a collection of modules that are built on top of NumPy.
702702

703-
We'll cover the SciPy versions in more detail soon.
703+
We'll cover the SciPy versions in more detail {doc}`soon <scipy>`.
704704

705705
For a comprehensive list of what's available in NumPy see [this documentation](https://docs.scipy.org/doc/numpy/reference/routines.html).
706706

@@ -716,7 +716,7 @@ Consider the polynomial expression
716716
p(x) = a_0 + a_1 x + a_2 x^2 + \cdots a_N x^N = \sum_{n=0}^N a_n x^n
717717
```
718718

719-
Earlier, you wrote a simple function `p(x, coeff)` to evaluate `np_polynom` without considering efficiency.
719+
{doc}`Earlier <pyess_ex2>`, you wrote a simple function `p(x, coeff)` to evaluate {doc}`np_polynom <np_polynom>` without considering efficiency.
720720

721721
Now write a new function that does the same job, but uses NumPy arrays and array operations for its computations, rather than any form of Python loop.
722722

@@ -771,7 +771,7 @@ If you can, write the method so that `draw(k)` returns `k` draws from `q`.
771771

772772
### Exercise 3
773773

774-
Recall our earlier discussion of the empirical cumulative distribution function.
774+
Recall our {doc}`earlier discussion <oop_ex1>` of the empirical cumulative distribution function.
775775

776776
Your task is to
777777

Collapse file

‎source/rst/pandas.md‎

Copy file name to clipboardExpand all lines: source/rst/pandas.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ Complete the program to plot the result as a bar graph like this one:
462462

463463
### Exercise 2
464464

465-
Using the method `read_data` introduced in Exercise 1, write a program to obtain year-on-year percentage change for the following indices:
465+
Using the method `read_data` introduced in {doc}`Exercise 1 <pd_ex1>`, write a program to obtain year-on-year percentage change for the following indices:
466466

467467
```{code-block} python3
468468
indices_list = {'^GSPC': 'S&P 500',
@@ -516,7 +516,7 @@ plt.show()
516516

517517
### Exercise 2
518518

519-
Following the work you did in Exercise 1, you can query the data using `read_data` by updating the start and end dates accordingly.
519+
Following the work you did in {doc}`Exercise 1 <pd_ex1>`, you can query the data using `read_data` by updating the start and end dates accordingly.
520520

521521
```{code-block} python3
522522
indices_data = read_data(
Collapse file

‎source/rst/parallelization.md‎

Copy file name to clipboardExpand all lines: source/rst/parallelization.md
+3-3Lines changed: 3 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ distributes them to different threads.
146146
Over the last few years, NumPy has managed to push this kind of multithreading
147147
out to more and more operations.
148148

149-
For example, let's return to a maximization problem discussed previously:
149+
For example, let's return to a maximization problem {doc}`discussed previously <ufuncs>`:
150150

151151
```{code-block} python3
152152
def f(x, y):
@@ -176,7 +176,7 @@ To get some basis for comparison for the last example, let's try the same
176176
thing with Numba.
177177

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

181181
```{code-block} python3
182182
from numba import vectorize
@@ -406,7 +406,7 @@ When you see us using ordinary `range` in a jitted function, it is either becaus
406406

407407
### Exercise 1
408408

409-
In an earlier exercise, we used Numba to accelerate an
409+
In {doc}`an earlier exercise <speed_ex1>`, we used Numba to accelerate an
410410
effort to compute the constant $\pi$ by Monte Carlo.
411411

412412
Now try adding parallelization and see if you get further speed gains.
Collapse file

‎source/rst/python_advanced_features.md‎

Copy file name to clipboardExpand all lines: source/rst/python_advanced_features.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ A variety of topics are treated in the lecture, including generators, exceptions
2929
single: Python; Iteration
3030
```
3131

32-
We've already said something about iterating in Python.
32+
We've {doc}`already said something <iterating_version_1>` about iterating in Python.
3333

3434
Now let's look more closely at how it all works, focusing in Python's implementation of the `for` loop.
3535

@@ -47,7 +47,7 @@ Formally, an *iterator* is an object with a `__next__` method.
4747

4848
For example, file objects are iterators .
4949

50-
To see this, let's have another look at the US cities data,
50+
To see this, let's have another look at the {doc}`US cities data <us_cities_data>`,
5151
which is written to the present working directory in the following cell
5252

5353
```{code-block} ipython
Collapse file

‎source/rst/python_by_example.md‎

Copy file name to clipboardExpand all lines: source/rst/python_by_example.md
+5-5Lines changed: 5 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The objective is to introduce you to basic Python syntax and data structures.
2626

2727
Deeper concepts will be covered in later lectures.
2828

29-
You should have read the lecture on getting started with Python before beginning this one.
29+
You should have read the {doc}`lecture <getting_started>` on getting started with Python before beginning this one.
3030

3131
## The Task: Plotting a White Noise Process
3232

@@ -72,7 +72,7 @@ Let's break this program down and see how it works.
7272
The first two lines of the program import functionality from external code
7373
libraries.
7474

75-
The first line imports NumPy, a favorite Python package for tasks like
75+
The first line imports {doc}`NumPy <numpy>`, a favorite Python package for tasks like
7676

7777
* working with arrays (vectors and matrices)
7878
* common mathematical functions like `cos` and `sqrt`
@@ -194,7 +194,7 @@ We can and will look at various ways to configure and improve this plot below.
194194

195195
## Alternative Implementations
196196

197-
Let's try writing some alternative versions of our first program, which plotted IID draws from the normal distribution.
197+
Let's try writing some alternative versions of {doc}`our first program <ourfirstprog>`, which plotted IID draws from the normal distribution.
198198

199199
The programs below are less efficient than the original one, and hence
200200
somewhat artificial.
@@ -294,7 +294,7 @@ x[1] # second element of x
294294
single: Python; For loop
295295
```
296296

297-
Now let's consider the `for` loop from the program above, which was
297+
Now let's consider the `for` loop from {doc}`the program above <firstloopprog>`, which was
298298

299299
```{code-block} python3
300300
for i in range(ts_length):
@@ -368,7 +368,7 @@ single: Python; While loop
368368

369369
The `for` loop is the most common technique for iteration in Python.
370370

371-
But, for the purpose of illustration, let's modify the program above to use a `while` loop instead.
371+
But, for the purpose of illustration, let's modify {doc}`the program above <firstloopprog>` to use a `while` loop instead.
372372

373373
```{code-block} python3
374374
ts_length = 100
Collapse file

‎source/rst/python_essentials.md‎

Copy file name to clipboardExpand all lines: source/rst/python_essentials.md
+6-6Lines changed: 6 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ type(x)
112112

113113
Python has several basic types for storing collections of (possibly heterogeneous) data.
114114

115-
We've already discussed lists.
115+
We've {doc}`already discussed lists <lists_ref>`.
116116

117117
```{index}
118118
single: Python; Tuples
@@ -163,7 +163,7 @@ x
163163
y
164164
```
165165

166-
You've actually seen an example of this already.
166+
You've actually {doc}`seen an example of this <tuple_unpacking_example>` already.
167167

168168
Tuple unpacking is convenient and we'll use it often.
169169

@@ -564,7 +564,7 @@ Let's talk a bit more about functions, which are all important for good programm
564564

565565
### The Flexibility of Python Functions
566566

567-
As we discussed in the previous lecture, Python functions are very flexible.
567+
As we discussed in the {doc}`previous lecture <python_by_example>`, Python functions are very flexible.
568568

569569
In particular
570570

@@ -573,7 +573,7 @@ In particular
573573
* Any object can be passed to a function as an argument, including other functions.
574574
* A function can return any kind of object, including functions.
575575

576-
We already gave an example of how straightforward it is to pass a function to
576+
We already {doc}`gave an example <test_program_6>` of how straightforward it is to pass a function to
577577
a function.
578578

579579
Note that a function can have arbitrarily many `return` statements (including zero).
@@ -688,7 +688,7 @@ Here the function created by `lambda` is said to be *anonymous* because it was n
688688
single: Python; keyword arguments
689689
```
690690

691-
In a previous lecture, you came across the statement
691+
In a {doc}`previous lecture <python_by_example>`, you came across the statement
692692

693693
```{code-block} python3
694694
plt.plot(x, 'b-', label="white noise")
@@ -778,7 +778,7 @@ p(x)
778778
= \sum_{i=0}^n a_i x^i
779779
```
780780

781-
Write a function `p` such that `p(x, coeff)` that computes the value in `polynom0` given a point `x` and a list of coefficients `coeff`.
781+
Write a function `p` such that `p(x, coeff)` that computes the value in {doc}`polynom0 <polynom0>` given a point `x` and a list of coefficients `coeff`.
782782

783783
Try to use `enumerate()` in your loop.
784784

Collapse file

‎source/rst/python_oop.md‎

Copy file name to clipboardExpand all lines: source/rst/python_oop.md
+11-11Lines changed: 11 additions & 11 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ single: Python; Object-Oriented Programming
1818

1919
## Overview
2020

21-
In an earlier lecture, we learned some foundations of object-oriented programming.
21+
In an {doc}`earlier lecture <oop_intro>`, we learned some foundations of object-oriented programming.
2222

2323
The objectives of this lecture are
2424

@@ -72,7 +72,7 @@ Let's cover general OOP concepts before we specialize to Python.
7272
single: Object-Oriented Programming; Key Concepts
7373
```
7474

75-
As discussed an earlier lecture, in the OOP paradigm, data and functions are **bundled together** into "objects".
75+
As discussed an {doc}`earlier lecture <oop_intro>`, in the OOP paradigm, data and functions are **bundled together** into "objects".
7676

7777
An example is a Python list, which not only stores data but also knows how to sort itself, etc.
7878

@@ -302,7 +302,7 @@ There are no examples of the last rule in the preceding code but we will see som
302302

303303
In this section, we look at some more formal details related to classes and `self`
304304

305-
* You might wish to skip to the next section the first time you read this lecture.
305+
{doc}`the next section <oop_solow_growth>`* You might wish to skip to the first time you read this lecture.
306306
* You can return to these details after you've familiarized yourself with more examples.
307307

308308
Methods actually live inside a class object formed when the interpreter reads
@@ -368,15 +368,15 @@ Here
368368
* $n$ is the population growth rate
369369
* $\delta$ is the depreciation rate
370370

371-
A **steady state** of the model is a $k$ that solves `solow_lom` when $k_{t+1} = k_t = k$.
371+
A **steady state** of the model is a $k$ that solves {doc}`solow_lom <solow_lom>` when $k_{t+1} = k_t = k$.
372372

373373
Here's a class that implements this model.
374374

375375
Some points of interest in the code are
376376

377-
* An instance maintains a record of its current capital stock in the variable `self.k`.
378-
* The `h` method implements the right-hand side of `solow_lom`.
379-
* The `update` method uses `h` to update capital as per `solow_lom`.
377+
{doc}`solow_lom <solow_lom>`{doc}`solow_lom <solow_lom>`* An instance maintains a record of its current capital stock in the variable `self.k`.
378+
* The `h` method implements the right-hand side of .
379+
* The `update` method uses `h` to update capital as per .
380380
* Notice how inside `update` the reference to the local method `h` is `self.h`.
381381

382382
The methods `steady_state` and `generate_sequence` are fairly self-explanatory
@@ -666,7 +666,7 @@ ax.set_ylabel('$x_t$', fontsize=16)
666666
plt.show()
667667
```
668668

669-
On the horizontal axis is the parameter $r$ in `quadmap2`.
669+
On the horizontal axis is the parameter $r$ in {doc}`quadmap2 <quadmap2>`.
670670

671671
The vertical axis is the state space $[0, 1]$.
672672

@@ -780,7 +780,7 @@ Aim for clarity, not efficiency.
780780

781781
### Exercise 2
782782

783-
In an earlier exercise, you wrote a function for evaluating polynomials.
783+
In an {doc}`earlier exercise <pyess_ex2>`, you wrote a function for evaluating polynomials.
784784

785785
This exercise is an extension, where the task is to build a simple class called `Polynomial` for representing and manipulating polynomial functions such as
786786

@@ -791,11 +791,11 @@ p(x) = a_0 + a_1 x + a_2 x^2 + \cdots a_N x^N = \sum_{n=0}^N a_n x^n
791791
\qquad (x \in \mathbb{R})
792792
```
793793

794-
The instance data for the class `Polynomial` will be the coefficients (in the case of `polynom`, the numbers $a_0, \ldots, a_N$).
794+
The instance data for the class `Polynomial` will be the coefficients (in the case of {doc}`polynom <polynom>`, the numbers $a_0, \ldots, a_N$).
795795

796796
Provide methods that
797797

798-
1. Evaluate the polynomial `polynom`, returning $p(x)$ for any $x$.
798+
{doc}`polynom <polynom>`1. Evaluate the polynomial , returning $p(x)$ for any $x$.
799799
1. Differentiate the polynomial, replacing the original coefficients with those of its derivative $p'$.
800800

801801
Avoid using any `import` statements.

0 commit comments

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