You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1a85bf9
Browse filesBrowse the repository at this point in the historyBrowse files
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 number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ If the built-in functions don't cover what we need, we either need to import
88
88
functions or create our own.
89
89
90
90
Examples of importing and using functions
91
-
were given in the previous lecture
91
+
were given in the {doc}`previous lecture <python_by_example>`
92
92
93
93
Here's another one, which tests whether a given year is a leap year:
94
94
@@ -168,13 +168,13 @@ User-defined functions are important for improving the clarity of your code by
168
168
169
169
(Writing the same thing twice is [almost always a bad idea](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself))
170
170
171
-
We will say more about this later.
171
+
We will say more about this {doc}`later <writing_good_code>`.
172
172
173
173
## Applications
174
174
175
175
### Random Draws
176
176
177
-
Consider again this code from the previous lecture
177
+
Consider again this code from the {doc}`previous lecture <python_by_example>`
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 number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
19
19
```
20
20
21
21
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>`.
23
23
24
24
Let's start with some imports:
25
25
@@ -33,12 +33,12 @@ import matplotlib.pyplot as plt
33
33
34
34
## Overview
35
35
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.
37
37
38
38
Vectorization involves sending array processing
39
39
operations in batch to efficient low-level code.
40
40
41
-
However, as discussed previously, vectorization has several weaknesses.
41
+
However, as {doc}`discussed previously <numba-p_c_vectorization>`, vectorization has several weaknesses.
42
42
43
43
One is that it is highly memory-intensive when working with large amounts of data.
44
44
@@ -157,7 +157,7 @@ Numba attempts to generate fast machine code using the infrastructure provided b
157
157
158
158
It does this by inferring type information on the fly.
159
159
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.)
161
161
162
162
The basic idea is this:
163
163
@@ -187,7 +187,7 @@ qm_numba = jit(qm)
187
187
188
188
In practice this would typically be done using an alternative *decorator* syntax.
189
189
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.)
191
191
192
192
Let's see how this is done.
193
193
@@ -264,7 +264,7 @@ If a class is successfully compiled, then its methods act as JIT-compiled
264
264
functions.
265
265
266
266
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>`.
268
268
269
269
To compile this class we use the `@jitclass` decorator:
270
270
@@ -379,7 +379,7 @@ If you prefer, you can safely skip this section.
379
379
380
380
### Cython
381
381
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.
383
383
384
384
As was the case with Numba, a key problem is the fact that Python is dynamically typed.
385
385
@@ -461,7 +461,7 @@ When Numba compiles machine code for functions, it treats global variables as co
461
461
462
462
### Exercise 1
463
463
464
-
Previously we considered how to approximate $\pi$ by
464
+
{doc}`Previously <pbe_ex3>` we considered how to approximate $\pi$ by
465
465
Monte Carlo.
466
466
467
467
Use the same idea here, but make the code efficient using Numba.
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 number
Diff line number
Diff line change
@@ -503,7 +503,7 @@ a
503
503
What's happened is that we have changed `a` by changing `b`.
504
504
505
505
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>`).
507
507
508
508
Hence, it has equal rights to make changes to that array.
509
509
@@ -700,7 +700,7 @@ single: Python; SciPy
700
700
701
701
Much of this functionality is also available in [SciPy](http://www.scipy.org/), a collection of modules that are built on top of NumPy.
702
702
703
-
We'll cover the SciPy versions in more detail soon.
703
+
We'll cover the SciPy versions in more detail {doc}`soon <scipy>`.
704
704
705
705
For a comprehensive list of what's available in NumPy see [this documentation](https://docs.scipy.org/doc/numpy/reference/routines.html).
706
706
@@ -716,7 +716,7 @@ Consider the polynomial expression
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 number
Diff line number
Diff line change
@@ -462,7 +462,7 @@ Complete the program to plot the result as a bar graph like this one:
462
462
463
463
### Exercise 2
464
464
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:
466
466
467
467
```{code-block} python3
468
468
indices_list = {'^GSPC': 'S&P 500',
@@ -516,7 +516,7 @@ plt.show()
516
516
517
517
### Exercise 2
518
518
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.
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 number
Diff line number
Diff line change
@@ -146,7 +146,7 @@ distributes them to different threads.
146
146
Over the last few years, NumPy has managed to push this kind of multithreading
147
147
out to more and more operations.
148
148
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>`:
150
150
151
151
```{code-block} python3
152
152
def f(x, y):
@@ -176,7 +176,7 @@ To get some basis for comparison for the last example, let's try the same
176
176
thing with Numba.
177
177
178
178
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.
180
180
181
181
```{code-block} python3
182
182
from numba import vectorize
@@ -406,7 +406,7 @@ When you see us using ordinary `range` in a jitted function, it is either becaus
406
406
407
407
### Exercise 1
408
408
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
410
410
effort to compute the constant $\pi$ by Monte Carlo.
411
411
412
412
Now try adding parallelization and see if you get further speed gains.
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 number
Diff line number
Diff line change
@@ -112,7 +112,7 @@ type(x)
112
112
113
113
Python has several basic types for storing collections of (possibly heterogeneous) data.
114
114
115
-
We've already discussed lists.
115
+
We've {doc}`already discussed lists <lists_ref>`.
116
116
117
117
```{index}
118
118
single: Python; Tuples
@@ -163,7 +163,7 @@ x
163
163
y
164
164
```
165
165
166
-
You've actually seen an example of this already.
166
+
You've actually {doc}`seen an example of this <tuple_unpacking_example>` already.
167
167
168
168
Tuple unpacking is convenient and we'll use it often.
169
169
@@ -564,7 +564,7 @@ Let's talk a bit more about functions, which are all important for good programm
564
564
565
565
### The Flexibility of Python Functions
566
566
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.
568
568
569
569
In particular
570
570
@@ -573,7 +573,7 @@ In particular
573
573
* Any object can be passed to a function as an argument, including other functions.
574
574
* A function can return any kind of object, including functions.
575
575
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
577
577
a function.
578
578
579
579
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
688
688
single: Python; keyword arguments
689
689
```
690
690
691
-
In a previous lecture, you came across the statement
691
+
In a {doc}`previous lecture <python_by_example>`, you came across the statement
692
692
693
693
```{code-block} python3
694
694
plt.plot(x, 'b-', label="white noise")
@@ -778,7 +778,7 @@ p(x)
778
778
= \sum_{i=0}^n a_i x^i
779
779
```
780
780
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`.
On the horizontal axis is the parameter $r$ in `quadmap2`.
669
+
On the horizontal axis is the parameter $r$ in {doc}`quadmap2 <quadmap2>`.
670
670
671
671
The vertical axis is the state space $[0, 1]$.
672
672
@@ -780,7 +780,7 @@ Aim for clarity, not efficiency.
780
780
781
781
### Exercise 2
782
782
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.
784
784
785
785
This exercise is an extension, where the task is to build a simple class called `Polynomial` for representing and manipulating polynomial functions such as
0 commit comments