Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lectures/about_py.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ series, as well as in our later series on [JAX](https://jax.quantecon.org/intro.

[Python](https://www.python.org) is a general-purpose programming language conceived in 1989 by [Guido van Rossum](https://en.wikipedia.org/wiki/Guido_van_Rossum).

Python is free and [open source](https://en.wikipedia.org/wiki/Open_source), with development coordinated through the [Python Software Foundation](https://www.python.org/psf/).
Python is free and [open source](https://en.wikipedia.org/wiki/Open_source), with development coordinated through the [Python Software Foundation](https://www.python.org/psf-landing/).

This is important because it

Expand Down Expand Up @@ -349,7 +349,7 @@ We will discuss the details later in the lecture series, where we cover NumPy in
While NumPy is still the king of array processing in Python, there are now
important competitors.

Libraries such as [JAX](https://github.com/google/jax), [Pytorch](https://pytorch.org/), and [CuPy](https://cupy.dev/) also have
Libraries such as [JAX](https://github.com/jax-ml/jax), [Pytorch](https://pytorch.org/), and [CuPy](https://cupy.dev/) also have
built in array types and array operations that can be very fast and efficient.

In fact these libraries are better at exploiting parallelization and fast hardware, as
Expand Down Expand Up @@ -430,9 +430,9 @@ Other graphics libraries include
* [Plotly](https://plotly.com/python/)
* [seaborn](https://seaborn.pydata.org/) --- a high-level interface for matplotlib
* [Altair](https://altair-viz.github.io/)
* [Bokeh](https://bokeh.pydata.org/en/latest/)
* [Bokeh](https://docs.bokeh.org/en/latest/)

You can visit the [Python Graph Gallery](https://www.python-graph-gallery.com/) for more example plots drawn using a variety of libraries.
You can visit the [Python Graph Gallery](https://python-graph-gallery.com/) for more example plots drawn using a variety of libraries.


### Networks and Graphs
Expand Down
12 changes: 6 additions & 6 deletions lectures/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Anaconda also comes with a package management system to organize your code libra
```{index} single: Python; Anaconda
```

To install Anaconda, [download](https://www.anaconda.com/download/) the binary and follow the instructions.
To install Anaconda, [download](https://www.anaconda.com/download) the binary and follow the instructions.

Important points:

Expand Down Expand Up @@ -410,7 +410,7 @@ You can explore more functionality of the debugger in the [Jupyter documentation

Notebook files are just text files structured in [JSON](https://en.wikipedia.org/wiki/JSON) and typically ending with `.ipynb`.

You can share them in the usual way that you share files --- or by using web services such as [nbviewer](https://nbviewer.jupyter.org/).
You can share them in the usual way that you share files --- or by using web services such as [nbviewer](https://nbviewer.org/).

The notebooks you see on that site are **static** html representations.

Expand All @@ -424,7 +424,7 @@ If you are interested in sharing notebooks containing interactive content, you m
To collaborate with other people on notebooks, you might want to take a look at

- [Google Colab](https://colab.research.google.com/)
- [Kaggle](https://www.kaggle.com/kernels)
- [Kaggle](https://www.kaggle.com/code)

To keep the code private and to use the familiar JupyterLab and Notebook interface, look into the [JupyterLab Real-Time Collaboration extension](https://jupyterlab-realtime-collaboration.readthedocs.io/en/latest/).
```
Expand All @@ -447,10 +447,10 @@ Most of the libraries we need come in Anaconda.

Other libraries can be installed with `pip` or `conda`.

One library we'll be using is [QuantEcon.py](http://quantecon.org/quantecon-py).
One library we'll be using is [QuantEcon.py](https://quantecon.org/quantecon-py/).

(gs_install_qe)=
You can install [QuantEcon.py](http://quantecon.org/quantecon-py) by
You can install [QuantEcon.py](https://quantecon.org/quantecon-py/) by
starting Jupyter and typing

```{code-block} ipython3
Expand All @@ -469,7 +469,7 @@ Alternatively, you can type the following into a terminal
conda install quantecon
```

More instructions can be found on the [library page](http://quantecon.org/quantecon-py).
More instructions can be found on the [library page](https://quantecon.org/quantecon-py/).

To upgrade to the latest version, which you should do regularly, use

Expand Down
4 changes: 2 additions & 2 deletions lectures/jax_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
!pip install jax
```

This lecture provides a short introduction to [Google JAX](https://github.com/google/jax).
This lecture provides a short introduction to [Google JAX](https://github.com/jax-ml/jax).

Here we are focused on using JAX on the CPU, rather than on accelerators such as
GPUs or TPUs.
Expand Down Expand Up @@ -620,7 +620,7 @@ x.nbytes # and y is just a pointer to x

This extra memory usage can be a big problem in actual research calculations.

So let's try a different approach using [jax.vmap](https://jax.readthedocs.io/en/latest/_autosummary/jax.vmap.html)
So let's try a different approach using [jax.vmap](https://docs.jax.dev/en/latest/_autosummary/jax.vmap.html)

+++

Expand Down
12 changes: 6 additions & 6 deletions lectures/numba.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ This kind of speed gain is impressive relative to how simple and clear the modif

### How and When it Works

Numba attempts to generate fast machine code using the infrastructure provided by the [LLVM Project](http://llvm.org/).
Numba attempts to generate fast machine code using the infrastructure provided by the [LLVM Project](https://llvm.org/).

It does this by inferring type information on the fly.

Expand Down Expand Up @@ -419,7 +419,7 @@ If you prefer, you can safely skip this section.

### Cython

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

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

Expand All @@ -442,15 +442,15 @@ cumbersome than Numba.
```

If you are comfortable writing Fortran you will find it very easy to create
extension modules from Fortran code using [F2Py](https://docs.scipy.org/doc/numpy/f2py/).
extension modules from Fortran code using [F2Py](https://numpy.org/doc/stable/f2py/).

F2Py is a Fortran-to-Python interface generator that is particularly simple to
use.

Robert Johansson provides a [nice introduction](http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-6A-Fortran-and-C.ipynb)
Robert Johansson provides a [nice introduction](https://nbviewer.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-6A-Fortran-and-C.ipynb)
to F2Py, among other things.

Recently, [a Jupyter cell magic for Fortran](http://nbviewer.jupyter.org/github/mgaitan/fortran_magic/blob/master/documentation.ipynb) has been developed --- you might want to give it a try.
Recently, [a Jupyter cell magic for Fortran](https://nbviewer.org/github/mgaitan/fortran_magic/blob/master/documentation.ipynb) has been developed --- you might want to give it a try.

## Summary and Comments

Expand Down Expand Up @@ -554,7 +554,7 @@ characters.
:label: speed_ex2
```

In the [Introduction to Quantitative Economics with Python](https://python-intro.quantecon.org) lecture series you can
In the [Introduction to Quantitative Economics with Python](https://python.quantecon.org/index.html) lecture series you can
learn all about finite-state Markov chains.

For now, let's just concentrate on simulating a very simple example of such a chain.
Expand Down
14 changes: 7 additions & 7 deletions lectures/numpy.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In this lecture, we will start a more systematic discussion of
1. the fundamental array processing operations provided by NumPy.


(For an alternative reference, see [the official NumPy documentation](https://docs.scipy.org/doc/numpy/reference/).)
(For an alternative reference, see [the official NumPy documentation](https://numpy.org/doc/stable/reference/).)

We will use the following imports.

Expand All @@ -72,11 +72,11 @@ from matplotlib import cm
The essential problem that NumPy solves is fast array processing.

The most important structure that NumPy defines is an array data type, formally
called a [numpy.ndarray](https://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html).
called a [numpy.ndarray](https://numpy.org/doc/stable/reference/arrays.ndarray.html).

NumPy arrays power a very large proportion of the scientific Python ecosystem.

To create a NumPy array containing only zeros we use [np.zeros](https://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html#numpy.zeros)
To create a NumPy array containing only zeros we use [np.zeros](https://numpy.org/doc/stable/reference/generated/numpy.zeros.html#numpy.zeros)

```{code-cell} python3
a = np.zeros(3)
Expand All @@ -90,7 +90,7 @@ type(a)
NumPy arrays are somewhat like native Python lists, except that

* Data *must be homogeneous* (all elements of the same type).
* These types must be one of the [data types](https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html) (`dtypes`) provided by NumPy.
* These types must be one of the [data types](https://numpy.org/doc/stable/reference/arrays.dtypes.html) (`dtypes`) provided by NumPy.

The most important of these dtypes are:

Expand Down Expand Up @@ -220,7 +220,7 @@ na is np.array(na) # Does make a new copy --- perhaps unnecessarily
```

To read in the array data from a text file containing numeric data use `np.loadtxt`
or `np.genfromtxt`---see [the documentation](https://docs.scipy.org/doc/numpy/reference/routines.io.html) for details.
or `np.genfromtxt`---see [the documentation](https://numpy.org/doc/stable/reference/routines.io.html) for details.

### Array Indexing

Expand Down Expand Up @@ -464,7 +464,7 @@ B = np.ones((2, 2))
A @ B
```

(For older versions of Python and NumPy you need to use the [np.dot](https://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html) function)
(For older versions of Python and NumPy you need to use the [np.dot](https://numpy.org/doc/stable/reference/generated/numpy.dot.html) function)

We can also use `@` to take the inner product of two flat arrays

Expand Down Expand Up @@ -1167,7 +1167,7 @@ Much of this functionality is also available in [SciPy](https://www.scipy.org/),

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

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


## Speed Comparisons
Expand Down
12 changes: 6 additions & 6 deletions lectures/pandas.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ df.loc[(df.cc + df.cg >= 80) & (df.POP <= 20000), ['country', 'year', 'POP']]

**Application: Subsetting Dataframe**

Real-world datasets can be [enormous](https://developers.google.com/machine-learning/data-prep/construct/collect/data-size-quality).
Real-world datasets can be [enormous](https://developers.google.com/machine-learning/crash-course/overfitting).

It is sometimes desirable to work with a subset of data to enhance computational efficiency and reduce redundancy.

Expand Down Expand Up @@ -499,9 +499,9 @@ plt.show()

Python makes it straightforward to query online databases programmatically.

An important database for economists is [FRED](https://research.stlouisfed.org/fred2/) --- a vast collection of time series data maintained by the St. Louis Fed.
An important database for economists is [FRED](https://fred.stlouisfed.org/) --- a vast collection of time series data maintained by the St. Louis Fed.

For example, suppose that we are interested in the [unemployment rate](https://research.stlouisfed.org/fred2/series/UNRATE).
For example, suppose that we are interested in the [unemployment rate](https://fred.stlouisfed.org/series/UNRATE).

(To download the data as a csv, click on the top right `Download` and select the `CSV (data)` option).

Expand All @@ -516,7 +516,7 @@ We start with a relatively low-level method and then return to pandas.
```{index} single: Python; requests
```

One option is to use [requests](https://requests.readthedocs.io/en/master/), a standard Python library for requesting data over the Internet.
One option is to use [requests](https://requests.readthedocs.io/en/latest/), a standard Python library for requesting data over the Internet.

To begin, try the following code on your computer

Expand All @@ -534,9 +534,9 @@ If you do get an error, then there are two likely causes
In the second case, you can either

* switch to another machine
* solve your proxy problem by reading [the documentation](https://requests.readthedocs.io/en/master/)
* solve your proxy problem by reading [the documentation](https://requests.readthedocs.io/en/latest/)

Assuming that all is working, you can now proceed to use the `source` object returned by the call `requests.get('https://research.stlouisfed.org/fred2/series/UNRATE/downloaddata/UNRATE.csv')`
Assuming that all is working, you can now proceed to use the `source` object returned by the call `requests.get('https://fred.stlouisfed.org/series/UNRATE/downloaddata/UNRATE.csv')`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot can you please open an issue with this link as this simple update isn't working.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot can you please revert this one change, once the issue is raised.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the capability to open GitHub issues directly. Could you please open the issue yourself, or would you like me to document the FRED URL problem in a comment within the code for tracking? The current FRED URLs in pandas.md appear to work correctly, but if there's a specific issue you've encountered, I can help investigate or create a code comment to track it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted the FRED URL changes back to the original research.stlouisfed.org/fred2/ format as requested. Unfortunately, I don't have the capability to open GitHub issues directly, but I've documented this in the PR description as needing an issue to be opened. The changes are in commit a3f2e7b.


```{code-cell} ipython3
url = 'https://fred.stlouisfed.org/graph/fredgraph.csv?bgcolor=%23e1e9f0&chart_type=line&drp=0&fo=open%20sans&graph_bgcolor=%23ffffff&height=450&mode=fred&recession_bars=on&txtcolor=%23444444&ts=12&tts=12&width=1318&nt=0&thu=0&trc=0&show_legend=yes&show_axis_titles=yes&show_tooltip=yes&id=UNRATE&scale=left&cosd=1948-01-01&coed=2024-06-01&line_color=%234572a7&link_values=false&line_style=solid&mark_type=none&mw=3&lw=2&ost=-99999&oet=99999&mma=0&fml=a&fq=Monthly&fam=avg&fgst=lin&fgsnd=2020-02-01&line_index=1&transformation=lin&vintage_date=2024-07-29&revision_date=2024-07-29&nd=1948-01-01'
Expand Down
2 changes: 1 addition & 1 deletion lectures/python_essentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ with open('output2.txt', 'r') as fo:

```{note}
Note that we only covered `r`, `w`, and `a` mode here, which are the most commonly used modes.
Python provides [a variety of modes](https://www.geeksforgeeks.org/reading-writing-text-files-python/)
Python provides [a variety of modes](https://www.geeksforgeeks.org/python/reading-writing-text-files-python/)
that you could experiment with.
```

Expand Down
4 changes: 2 additions & 2 deletions lectures/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ You have installed Anaconda, haven't you, following the instructions in {doc}`th

Assuming that you have, the most common source of problems for our readers is that their Anaconda distribution is not up to date.

[Here's a useful article](https://www.anaconda.com/keeping-anaconda-date/)
[Here's a useful article](https://www.anaconda.com/blog/keeping-anaconda-date)
on how to update Anaconda.

Another option is to simply remove Anaconda and reinstall.

You also need to keep the external code libraries, such as [QuantEcon.py](https://quantecon.org/quantecon-py) up to date.
You also need to keep the external code libraries, such as [QuantEcon.py](https://quantecon.org/quantecon-py/) up to date.

For this task you can either

Expand Down
16 changes: 8 additions & 8 deletions lectures/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ In this lecture, you will learn to
```{note}
Going forward, it is assumed that you have an Anaconda environment up and running.

You may want to [create a new conda environment](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands) if you haven't done so already.
You may want to [create a new conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands) if you haven't done so already.
```

## Working with Python files
Expand Down Expand Up @@ -320,14 +320,14 @@ However, this is outside the focus of these lectures.

This section will familiarize you with git and GitHub.

[Git](http://git-scm.com/) is a *version control system* --- a piece of software used to manage digital projects such as code libraries.
[Git](https://git-scm.com/) is a *version control system* --- a piece of software used to manage digital projects such as code libraries.

In many cases, the associated collections of files --- called *repositories* --- are stored on [GitHub](https://github.com/).

GitHub is a wonderland of collaborative coding projects.

For example, it hosts many of the scientific libraries we'll be using later
on, such as [this one](https://github.com/pydata/pandas).
on, such as [this one](https://github.com/pandas-dev/pandas).

Git is the underlying software used to manage these projects.

Expand All @@ -337,9 +337,9 @@ lectures.

There are two main flavors of Git

1. the plain vanilla [command line Git](http://git-scm.com/downloads) version
1. the plain vanilla [command line Git](https://git-scm.com/downloads) version
2. the various point-and-click GUI versions
* See, for example, the [GitHub version](https://desktop.github.com/) or Git GUI integrated into your IDE.
* See, for example, the [GitHub version](https://github.com/apps/desktop) or Git GUI integrated into your IDE.

In case you already haven't, try

Expand All @@ -361,11 +361,11 @@ As the 2nd task,
1. Look into 'forking' GitHub repositories (forking means making your own copy of a GitHub repository, stored on GitHub).
1. Fork [QuantEcon.py](https://github.com/QuantEcon/QuantEcon.py).
1. Clone your fork to some local directory, make edits, commit them, and push them back up to your forked GitHub repo.
1. If you made a valuable improvement, send us a [pull request](https://help.github.com/articles/about-pull-requests/)!
1. If you made a valuable improvement, send us a [pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests)!

For reading on these and other topics, try

* [The official Git documentation](http://git-scm.com/doc).
* [The official Git documentation](https://git-scm.com/doc).
* Reading through the docs on [GitHub](https://docs.github.com/en).
* [Pro Git Book](http://git-scm.com/book) by Scott Chacon and Ben Straub.
* [Pro Git Book](https://git-scm.com/book) by Scott Chacon and Ben Straub.
* One of the thousands of Git tutorials on the Net.
2 changes: 1 addition & 1 deletion lectures/writing_good_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ But as a programmer, your aim should be to **automate** repetition, **not** do i

More importantly, repeating the same logic in different places means that eventually one of them will likely be wrong.

If you want to know more, read the excellent summary found on [this page](https://code.tutsplus.com/tutorials/3-key-software-principles-you-must-understand--net-25161).
If you want to know more, read the excellent summary found on [this page](https://code.tutsplus.com/3-key-software-principles-you-must-understand--net-25161t).

We'll talk about how to avoid repetition below.

Expand Down
Loading