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
Copy file name to clipboardExpand all lines: lectures/scipy.md
+21-6Lines changed: 21 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,14 @@ kernelspec:
23
23
```{index} single: Python; SciPy
24
24
```
25
25
26
+
In addition to what’s in Anaconda, this lecture will need the following libraries:
27
+
28
+
```{code-cell} ipython3
29
+
:tags: [hide-output]
30
+
31
+
!pip install --upgrade quantecon
32
+
```
33
+
26
34
## Overview
27
35
28
36
[SciPy](https://scipy.org/) builds on top of NumPy to provide common tools for scientific programming such as
@@ -49,20 +57,27 @@ In this lecture, we aim only to highlight some useful parts of the package.
49
57
50
58
SciPy is a package that contains various tools that are built on top of NumPy, using its array data type and related functionality.
51
59
52
-
In older versions of SciPy, importing SciPy would also import NumPy symbols into the global namespace.
60
+
````{note}
61
+
In older versions of SciPy (`scipy < 0.15.1`), importing the package would also import NumPy symbols into the global namespace, as can be seen from this excerpt the SciPy initialization file:
53
62
54
-
However, modern versions of SciPy (1.15+) have a cleaner approach and no longer automatically import NumPy symbols. This is better practice as it avoids namespace pollution.
55
-
56
-
Instead, you should import NumPy explicitly:
63
+
```python
64
+
from numpy import *
65
+
from numpy.random import rand, randn
66
+
from numpy.fft import fft, ifft
67
+
from numpy.lib.scimath import *
68
+
```
57
69
70
+
However, it is better practice to use NumPy functionality explicitly.
58
71
59
-
```{code-cell} python3
72
+
```python
60
73
import numpy as np
61
-
import quantecon as qe
62
74
63
75
a = np.identity(3)
64
76
```
65
77
78
+
More recent versions of SciPy (1.15+) no longer automatically import NumPy symbols.
79
+
```
80
+
66
81
What is useful in SciPy is the functionality in its sub-packages
67
82
68
83
* `scipy.optimize`, `scipy.integrate`, `scipy.stats`, etc.
0 commit comments