Skip to content

Commit e168c7d

Browse files
mmckyclaude
andauthored
Repoint the ols, mle and phillips data reads to data-lectures (wave B1') (#1034)
Seven code-cell reads across three lectures, plus the prose download link in mle.md, now read QuantEcon/data-lectures instead of this repo's own committed blobs. The bytes are byte-identical — verified by sha256 in the landing PR — so no figure or coefficient changes. Reproduced from the new URL: ols.md's headline regression still gives n=111, b0=4.6261, b1=0.5319, R-squared=0.6113, the 4.63 / 0.53 / 0.611 the prose quotes. The files under lectures/_static/lecture_specific/ are deliberately NOT deleted here. This repo publishes on a `publish*` tag, so the already-published notebooks keep the old URLs until the next publish; deleting now would 404 them for every reader who opens a lecture in Colab. Deletion is a follow-up PR gated on the publish. Three details worth noting for review: * mle.md:160's prose link pointed at the published site (python.quantecon.org/_static/...), not at this repo. That URL survives a repoint and breaks only when the file is deleted and the site republishes — no automated check here would catch it, because jupyter-cache hashes code cells only, so a prose-only edit cache-hits and CI goes green. It also named `mle/fp.dta` inline, a path that does not exist in the flat published tree, so the filename in the sentence is corrected too. * phillips_drifts_volatilities.md built its URL by string concatenation across three source lines. The continuation is collapsed rather than patched: editing only the host line would have left 'NEWQDATA.csv' appended to a path that no longer exists. * The reads are normalised to the documented CPython form, github.com/QuantEcon/data-lectures/raw/main/lectures/<file>. NEWQDATA.csv previously used raw.githubusercontent.com, which is equally valid here; the uniform spelling makes the seven reads look like one change. Adds data-url-guard.yml, which this repo lacked. It is a copy of the one in lecture-python-intro with its comments corrected for this repo — intro's cites `exclude_patterns`, which this repo's _config.yml does not define. Part of QuantEcon/workspace-lectures#39. Data landed in QuantEcon/data-lectures#79. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
1 parent 06c784f commit e168c7d

4 files changed

Lines changed: 57 additions & 12 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# A dataset read that points at the wrong host fails in the reader's notebook,
2+
# not in CI. The data-audit dashboard that would catch it lives in
3+
# QuantEcon/data-lectures, runs on that repo's pushes and a weekly cron, and
4+
# never on a pull request here — so its detection lag is up to seven days.
5+
# This is the only check that fires at the moment of the change.
6+
#
7+
# It is also the only check here that fires on a PROSE edit. `ci.yml` executes
8+
# the book, but jupyter-cache hashes code cells only and restores a warm shared
9+
# cache, so a markdown link or a {download} role that points at a dead URL
10+
# cache-hits and goes green. Do not read a green `ci.yml` as evidence that a
11+
# prose link resolves.
12+
#
13+
# See QuantEcon/data-lectures PLAN.md, repoint rule 6.
14+
15+
name: Data URL guard
16+
17+
on:
18+
pull_request:
19+
push:
20+
branches: [main]
21+
22+
jobs:
23+
data-url-guard:
24+
runs-on: ubuntu-latest
25+
# This job greps a checkout and writes nothing. The repo default is
26+
# `write`, so without this it would receive a token that can also approve
27+
# pull request reviews.
28+
permissions:
29+
contents: read
30+
steps:
31+
- uses: actions/checkout@v7
32+
- name: No data-lectures read on the LFS media host
33+
run: |
34+
# media.githubusercontent.com is the LFS *media* endpoint and routes
35+
# per path: it serves a file only where that path is LFS-tracked in
36+
# the repo the URL names, and 404s otherwise. Everything data-lectures
37+
# publishes is plain git, so this host never resolves for it — and a
38+
# mechanical org/repo swap that preserves the host breaks every read.
39+
#
40+
# grep -r walks lectures/_static/** too. Nothing under _static is
41+
# executed by this repo's build (it is an asset path, and
42+
# `only_build_toc_files: true` builds exactly _toc.yml), and the
43+
# data-lectures audit excludes _static by design — so a bad URL in a
44+
# vendored notebook or script there is invisible everywhere else.
45+
if grep -rnF 'media.githubusercontent.com/media/QuantEcon/data-lectures' lectures/; then
46+
echo "::error::Read data-lectures over raw.githubusercontent.com (or the github.com/.../raw/ redirect), never media.githubusercontent.com — that host is LFS-only and 404s every file data-lectures publishes."
47+
exit 1
48+
fi
49+
echo "OK — no data-lectures read on the media host."

‎lectures/mle.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ Let's have a look at the distribution of the data we'll be working with in this
157157

158158
Treisman's main source of data is *Forbes'* annual rankings of billionaires and their estimated net worth.
159159

160-
The dataset `mle/fp.dta` can be downloaded from [here](https://python.quantecon.org/_static/lecture_specific/mle/fp.dta)
160+
The dataset `fp.dta` can be downloaded from [here](https://github.com/QuantEcon/data-lectures/raw/main/lectures/fp.dta)
161161
or its [AER page](https://www.aeaweb.org/articles?id=10.1257/aer.p20161068).
162162

163163
```{code-cell} ipython3
164164
# Load in data and view
165165
df = pd.read_stata(
166-
"https://github.com/QuantEcon/lecture-python.myst/raw/refs/heads/main/lectures/_static/lecture_specific/mle/fp.dta"
166+
"https://github.com/QuantEcon/data-lectures/raw/main/lectures/fp.dta"
167167
)
168168
df.head()
169169
```

‎lectures/ols.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ These variables and other data used in the paper are available for download on D
9191
We will use pandas' `.read_stata()` function to read in data contained in the `.dta` files to dataframes
9292

9393
```{code-cell} python3
94-
df1 = pd.read_stata('https://github.com/QuantEcon/lecture-python.myst/raw/refs/heads/main/lectures/_static/lecture_specific/ols/maketable1.dta')
94+
df1 = pd.read_stata('https://github.com/QuantEcon/data-lectures/raw/main/lectures/maketable1.dta')
9595
df1.head()
9696
```
9797

@@ -323,7 +323,7 @@ Let's estimate some of the extended models considered in the paper
323323
(Table 2) using data from `maketable2.dta`
324324

325325
```{code-cell} python3
326-
df2 = pd.read_stata('https://github.com/QuantEcon/lecture-python.myst/raw/refs/heads/main/lectures/_static/lecture_specific/ols/maketable2.dta')
326+
df2 = pd.read_stata('https://github.com/QuantEcon/data-lectures/raw/main/lectures/maketable2.dta')
327327
328328
# Add constant term to dataset
329329
df2['const'] = 1
@@ -475,7 +475,7 @@ used for estimation)
475475

476476
```{code-cell} python3
477477
# Import and select the data
478-
df4 = pd.read_stata('https://github.com/QuantEcon/lecture-python.myst/raw/refs/heads/main/lectures/_static/lecture_specific/ols/maketable4.dta')
478+
df4 = pd.read_stata('https://github.com/QuantEcon/data-lectures/raw/main/lectures/maketable4.dta')
479479
df4 = df4[df4['baseco'] == 1]
480480
481481
# Add a constant variable
@@ -603,7 +603,7 @@ results.
603603

604604
```{code-cell} python3
605605
# Load in data
606-
df4 = pd.read_stata('https://github.com/QuantEcon/lecture-python.myst/raw/refs/heads/main/lectures/_static/lecture_specific/ols/maketable4.dta')
606+
df4 = pd.read_stata('https://github.com/QuantEcon/data-lectures/raw/main/lectures/maketable4.dta')
607607
608608
# Add a constant term
609609
df4['const'] = 1
@@ -676,7 +676,7 @@ using `numpy` - your results should be the same as those in the
676676

677677
```{code-cell} python3
678678
# Load in data
679-
df1 = pd.read_stata('https://github.com/QuantEcon/lecture-python.myst/raw/refs/heads/main/lectures/_static/lecture_specific/ols/maketable1.dta')
679+
df1 = pd.read_stata('https://github.com/QuantEcon/data-lectures/raw/main/lectures/maketable1.dta')
680680
df1 = df1.dropna(subset=['logpgp95', 'avexpr'])
681681
682682
# Add a constant term

‎lectures/phillips_drifts_volatilities.md‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ from scipy.special import expit
9999
from scipy.stats import invwishart
100100
101101
102-
data_url = (
103-
'https://raw.githubusercontent.com/QuantEcon/lecture-python.myst/'
104-
'main/lectures/_static/lecture_specific/phillips_drifts_volatilities/'
105-
'NEWQDATA.csv'
106-
)
102+
data_url = 'https://github.com/QuantEcon/data-lectures/raw/main/lectures/NEWQDATA.csv'
107103
```
108104

109105
## Bad policy or bad luck?

0 commit comments

Comments
 (0)