From 50c998f093bb38a8ede56958c3153f307f049e13 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Fri, 7 Aug 2026 09:15:57 +1000 Subject: [PATCH] french_rev: read the five datasets from data-lectures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Repoints all five french_rev datasets onto QuantEcon/data-lectures: assignat.xlsx, dette.xlsx and fig_3.xlsx via the base_url f-string, and caron.npy and nom_balances.npy, which were local-path reads. The two .npy reads are the substantive fix. `np.load('datasets/caron.npy')` resolves only when the working directory happens to be `lectures/`, so the downloaded notebook raised FileNotFoundError in Colab and anywhere else a reader ran it. They now fetch over HTTP and load through BytesIO, matching the idiom lecture-wasm already uses. These were the last local-path data reads in this repo. The three markdown links under "Data Sources" are repointed too. They are prose, so no build checks them, and they would have 404'd once this repo's copies are deleted. Verified: all five served from data-lectures are byte-identical (sha256) to the copies this lecture read before, and to each dataset's manifest; both .npy files load to identical arrays, shape and dtype. This repo's copies under lectures/datasets/ are deliberately kept in this PR and deleted in a follow-up once the site is published, per repoint rule 3 — the published notebook lags main and would 404 in the gap. Part of QuantEcon/workspace-lectures#23. Data: QuantEcon/data-lectures#49. --- lectures/french_rev.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lectures/french_rev.md b/lectures/french_rev.md index 946f8642..078af708 100644 --- a/lectures/french_rev.md +++ b/lectures/french_rev.md @@ -57,18 +57,20 @@ We use matplotlib to replicate several of the graphs with which {cite}`sargent_ ## Data Sources This lecture uses data from three spreadsheets assembled by {cite}`sargent_velde1995`: - * [datasets/fig_3.xlsx](https://github.com/QuantEcon/lecture-python-intro/blob/main/lectures/datasets/fig_3.xlsx) - * [datasets/dette.xlsx](https://github.com/QuantEcon/lecture-python-intro/blob/main/lectures/datasets/dette.xlsx) - * [datasets/assignat.xlsx](https://github.com/QuantEcon/lecture-python-intro/blob/main/lectures/datasets/assignat.xlsx) + * [fig_3.xlsx](https://github.com/QuantEcon/data-lectures/blob/main/lectures/fig_3.xlsx) + * [dette.xlsx](https://github.com/QuantEcon/data-lectures/blob/main/lectures/dette.xlsx) + * [assignat.xlsx](https://github.com/QuantEcon/data-lectures/blob/main/lectures/assignat.xlsx) ```{code-cell} ipython3 import numpy as np import pandas as pd import matplotlib.pyplot as plt +from io import BytesIO +import requests plt.rcParams.update({'font.size': 12}) -base_url = 'https://github.com/QuantEcon/lecture-python-intro/raw/'\ - + 'main/lectures/datasets/' +base_url = 'https://github.com/QuantEcon/data-lectures/raw/'\ + + 'main/lectures/' fig_3_url = f'{base_url}fig_3.xlsx' dette_url = f'{base_url}dette.xlsx' @@ -706,8 +708,10 @@ def fit(x, y): ```{code-cell} ipython3 # Load data -caron = np.load('datasets/caron.npy') -nom_balances = np.load('datasets/nom_balances.npy') +caron_response = requests.get(f'{base_url}caron.npy') +nom_balances_response = requests.get(f'{base_url}nom_balances.npy') +caron = np.load(BytesIO(caron_response.content)) +nom_balances = np.load(BytesIO(nom_balances_response.content)) infl = np.concatenate(([np.nan], -np.log(caron[1:63, 1] / caron[0:62, 1])))