From 62e3c22484b1cdca3b21e843ded6e32a6071fa96 Mon Sep 17 00:00:00 2001 From: ***** <721466+soodoku@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:28:07 -0800 Subject: [PATCH] Enforce American spelling with codespell Co-Authored-By: Claude Fable 5.2 --- .codespellrc | 4 ++++ .github/workflows/codespell.yml | 18 ++++++++++++++++++ ms/ms.tex | 14 +++++++------- src/s01_load.py | 6 +++--- src/s03_design.py | 2 +- src/s05_inference.py | 2 +- src/s06_specification.py | 2 +- src/s07_falsification.py | 8 ++++---- src/s09_magnitude.py | 2 +- src/s13_streaming.py | 4 ++-- src/utils.py | 2 +- tests/test_guards.py | 2 +- 12 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 .codespellrc create mode 100644 .github/workflows/codespell.yml diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..197e5ad --- /dev/null +++ b/.codespellrc @@ -0,0 +1,4 @@ +[codespell] +builtin = clear,rare,en-GB_to_en-US +skip = *.pdf,*.png,*.jpg,*.jpeg,*.gif,*.csv,*.tsv,*.json,*.geojson,*.graphml,*.ipynb,*.html,*.svg,*.bib,*.bbl,*.lock,*.parquet,*.rda,*.rds,*.RData,*.dta,*.xlsx,*.xml,*.min.js,*.map,*.log,*.aux,./data,./tabs +ignore-words-list = analogue,favourable,judgement,neighbouring,pregression diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 0000000..cc542c0 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,18 @@ +name: codespell + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + codespell: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: codespell-project/actions-codespell@e3258cca84ce02b0bb36a3d41f2c18f719a0cc1a # v2.4.3 diff --git a/ms/ms.tex b/ms/ms.tex index 3abc70e..25510ee 100644 --- a/ms/ms.tex +++ b/ms/ms.tex @@ -59,7 +59,7 @@ ($SE = \numSEClustered$, clustered by album). Weekday comparisons do not account for the estimated association under the tested specifications: ten Fridays drawn at random reach the observed effect \numFridayPlaceboDraws{} times in ten thousand, the mean Friday residual after the paper's fixed effects is a seventh of a death, and a model-free contrast -of each release against its own neighbouring Fridays gives $+\numEffectAdjacentFriday$, a ratio +of each release against its own neighboring Fridays gives $+\numEffectAdjacentFriday$, a ratio the original authors also report. Applying the estimator to the same calendar positions in other years returns \numEffectCalendarPlacebo{}. @@ -113,7 +113,7 @@ \section{Introduction} estimated release association under the tested specifications. Ten Fridays drawn at random reach the observed effect \numFridayPlaceboDraws{} times in ten thousand; the comparison is unchanged by whether weekday fixed effects are in the model at all; letting the Friday effect vary by season and by year moves the estimate by about a death; a -contrast of each release against its own neighbouring Fridays, which uses no model, recovers a +contrast of each release against its own neighboring Fridays, which uses no model, recovers a ratio the original authors also report; and applying the estimator to the same calendar positions in other years returns \numEffectCalendarPlacebo{}. The day $-6$ coefficient that looks like a pre-trend is a Saturday, and the actual previous Friday is flat. @@ -144,7 +144,7 @@ \section{Replication} The reported and replicated estimates are close. \citeauthor{patel2026smartphones} report $+18.2$ deaths. We estimate $+\numEffectRegression$ deaths ($SE = \numSEClustered$), a \numPctRegression\% increase on a control-day mean of \numControlMean{} fatalities, which is the -analogue of the 120.9 they report. The point estimates differ by \numDiffFromPaper{} deaths, well +analog of the 120.9 they report. The point estimates differ by \numDiffFromPaper{} deaths, well within one standard error. Our wider standard error reflects album-level clustering, which is the natural adjustment when @@ -232,7 +232,7 @@ \subsection{Day of Week} The event study appears at first to say otherwise, with a coefficient of $+16.5$ on day $-6$, nearly the size of the release-day coefficient. Day $-6$ is not the previous Friday. For nine of the ten albums it is the Saturday before release. The previous Friday is day $-7$, at $+3.8$ -($t = 0.92$), and the following Friday is day $+7$, at $-0.3$. Both same-weekday neighbours are +($t = 0.92$), and the following Friday is day $+7$, at $-0.3$. Both same-weekday neighbors are quiet, which is the adjacent-Friday contrast read off the event study. A joint test of flatness across the ten pre-treatment days, flipping the sign of each album's whole residual vector so that the correlation induced by using the same ten albums for every coefficient is respected, returns @@ -240,7 +240,7 @@ \subsection{Day of Week} \subsection{Calendar Position} -Labels choose release dates, so the dates are not random. If the choice favours positions that are +Labels choose release dates, so the dates are not random. If the choice favors positions that are also high-risk, the estimate picks that up. Applying each album's date to every other year in the series, matched to the nearest same weekday, reproduces the seasonal and holiday context without the album. Those \numNCalendarPlacebo{} placebo dates average \numEffectCalendarPlacebo{} deaths @@ -336,7 +336,7 @@ \subsection{The Mechanism Is Untested} Applying the estimator to variables that describe the crashes rather than counting them turns up one result. Mean crash latitude is $+0.37$ degrees on release days ($t = 2.91$). This is not a -placebo failure, because latitude summarises the same crashes whose count is the outcome and is +placebo failure, because latitude summarizes the same crashes whose count is the outcome and is therefore not independent of treatment. Neither is it demonstrably a composition artifact: if the extra crashes dragged the mean, albums with the largest excess would show the largest shift, and the correlation across the ten is \numRLatitudeExcess{} ($p = \numPLatitudeExcess$), with @@ -388,7 +388,7 @@ \subsection{The Effect Belongs to the Ten Albums, Not to Releases That Size} are $\numNDoseMatched$ such albums and they average $\numEffectDoseMatched$ deaths ($SE = \numEffectDoseMatchedSE$, 95\% CI $[\numEffectDoseMatchedLo, \numEffectDoseMatchedHi]$), against $+\numEffectResidual$ for the ten. The comparison set -is a rule rather than a judgement about which releases were major: reach +is a rule rather than a judgment about which releases were major: reach $\numDoseCut$ million first-day US streams and you are in it. Getting to that comparison took two corrections to the paper's dose. The first is that diff --git a/src/s01_load.py b/src/s01_load.py index 1d78337..cb587bf 100644 --- a/src/s01_load.py +++ b/src/s01_load.py @@ -76,10 +76,10 @@ def load_local_fars(directory="."): """ Load FARS Accident CSVs downloaded manually from NHTSA. - Column names are normalised to upper case before concatenation. FARS is + Column names are normalized to upper case before concatenation. FARS is not consistent about case across vintages: the 2007 file names its coordinate columns `latitude` and `longitud` while every later file uses - `LATITUDE` and `LONGITUD`. Concatenating without normalising produces two + `LATITUDE` and `LONGITUD`. Concatenating without normalizing produces two columns for one variable, so `df["LATITUDE"]` returns a DataFrame rather than a Series and any code doing `{c.upper(): c for c in df.columns}` silently keeps whichever came last, dropping the other year's values. @@ -87,7 +87,7 @@ def load_local_fars(directory="."): The 2021 and 2022 files also carry a UTF-8 byte-order mark, which makes their first column `\ufeffSTATE` rather than `STATE`. Any lookup by name misses it, silently, for exactly those two years. Both problems are - normalised away here rather than worked around at each call site. + normalized away here rather than worked around at each call site. """ frames = [] for f in sorted(Path(directory).glob("*ccident*.csv")): diff --git a/src/s03_design.py b/src/s03_design.py index 5ce6380..fff90f7 100644 --- a/src/s03_design.py +++ b/src/s03_design.py @@ -456,7 +456,7 @@ def _modal_weekday(day_offset): Nine of the ten releases are Fridays, so day -7 and +7 are Fridays and day -6 is a Saturday. Naming the weekday in the output stops the event - study from being read as though the neighbouring same-weekday days were + study from being read as though the neighboring same-weekday days were somewhere else in the window. """ names = [ diff --git a/src/s05_inference.py b/src/s05_inference.py index 9532cb1..69b1236 100644 --- a/src/s05_inference.py +++ b/src/s05_inference.py @@ -203,7 +203,7 @@ def robustness_to_one_day(df_global, albums=None, n_sims=20000, seed=42): recomputed with the single most influential album removed. The randomization p-value for the median compares the observed median with - medians of ten days drawn at random, which is the rank analogue of the + medians of ten days drawn at random, which is the rank analog of the randomization inference run on the mean elsewhere. Returns DataFrame with one row per statistic. diff --git a/src/s06_specification.py b/src/s06_specification.py index 37b69c3..7560ae8 100644 --- a/src/s06_specification.py +++ b/src/s06_specification.py @@ -583,7 +583,7 @@ def release_day_weather(accidents, albums=None, window=10): That second question matters because these shares are computed from the crashes that happened, not from weather stations. They are a composition measure of the outcome rather than an exogenous covariate, so conditioning - on them risks controlling for a consequence of treatment. The defence is + on them risks controlling for a consequence of treatment. The defense is not that the risk is theoretical but that the shares do not move on release days, which is reported here. A cleaner design would use station weather weighted by population; this repository does not have it. diff --git a/src/s07_falsification.py b/src/s07_falsification.py index 7dbe710..3f7f40c 100644 --- a/src/s07_falsification.py +++ b/src/s07_falsification.py @@ -374,7 +374,7 @@ def friday_placebo_test(df_global, n_sims=10000, n_pick=10, seed=42): and ask how often the placebo reaches the observed effect. Draws are from `resid_global`, which already nets out day-of-week, month, year - and holiday fixed effects, so the null distribution is centred at zero by + and holiday fixed effects, so the null distribution is centered at zero by construction. That is the point: after the paper's controls there is no Friday contrast left for a placebo to pick up. @@ -657,7 +657,7 @@ def calendar_position_placebo(df_global, albums=None, window=10): """ Are these calendar positions dangerous, album or no album? - Labels choose release dates, so the dates are not random. If they favour + Labels choose release dates, so the dates are not random. If they favor positions that are also high-risk, a holiday weekend or the start of a travel season, the release-day estimate picks that up. The test applies each album's calendar position to every other year in the series, matched @@ -846,7 +846,7 @@ def adjacent_friday_contrast(daily_df, albums=None, offsets=(-14, -7, 7, 14)): The random-Friday placebo already answers the day-of-week objection, but it answers it through a model: the comparison runs on residuals from a fixed effects fit. This does not. For each Friday release it compares the release - day with the same album's own neighbouring Fridays, so the contrast is held + day with the same album's own neighboring Fridays, so the contrast is held at the same weekday, the same season and the same year by construction, and no dummy has to do any absorbing. @@ -855,7 +855,7 @@ def adjacent_friday_contrast(daily_df, albums=None, offsets=(-14, -7, 7, 14)): even though it agrees in magnitude with the fixed-effects estimate. Patel et al. run the same comparison and report an odds ratio of 1.10. - Donda is excluded: it is the one Sunday release, and it has no neighbouring + Donda is excluded: it is the one Sunday release, and it has no neighboring Fridays to be compared with. Returns DataFrame with one row per album and a pooled row. diff --git a/src/s09_magnitude.py b/src/s09_magnitude.py index d15a63f..eaa81e1 100644 --- a/src/s09_magnitude.py +++ b/src/s09_magnitude.py @@ -89,7 +89,7 @@ def power_analysis( # The calculation is only as relevant as the estimator it models, and there # are three candidate standard errors for one quantity. Running all three - # shows which way the choice cuts: the null SE is the most favourable to + # shows which way the choice cuts: the null SE is the most favorable to # the published estimate, and it is the one quoted in the text. se_options = [ ("null (residual SD / sqrt n)", se_null), diff --git a/src/s13_streaming.py b/src/s13_streaming.py index 519cfd3..de36276 100644 --- a/src/s13_streaming.py +++ b/src/s13_streaming.py @@ -247,7 +247,7 @@ def paper_album_keys(first_day, albums=None): nine albums the paper never studied, at doses an order of magnitude below the real ones. The key is lead artist and date together. - Lead artist needs normalising because a joint credit is stored two ways. + Lead artist needs normalizing because a joint credit is stored two ways. Her Loss is "Drake & 21 Savage" in the album list and "Drake|21 Savage" in the chart, whose lead is "Drake". """ @@ -281,7 +281,7 @@ def dose_matched_contrast(per_album, first_day, albums=None, years=(2018, 2022)) This is a rule, not a list. Nothing about it depends on which albums anyone considered major, and the comparison albums are matched on the paper's own - treatment intensity rather than on a judgement about fame. + treatment intensity rather than on a judgment about fame. The year restriction is reported because the comparison albums run to 2024 while the paper's stop in 2022. It is a check, not the headline: the diff --git a/src/utils.py b/src/utils.py index c9cd5e0..cc0dd2f 100644 --- a/src/utils.py +++ b/src/utils.py @@ -21,7 +21,7 @@ def album_stats(values, alpha=0.05): """ - Summarise a set of per-album effects. + Summarize a set of per-album effects. Album-level effects are averages over a handful of treated units, so the standard error uses the sample standard deviation (ddof=1) and critical diff --git a/tests/test_guards.py b/tests/test_guards.py index f0fa387..a977ce7 100644 --- a/tests/test_guards.py +++ b/tests/test_guards.py @@ -156,7 +156,7 @@ class TestColumnNormalisation: """FARS is inconsistent about column case across vintages. The 2007 file names its coordinates `latitude` and `longitud`; every later - file uses upper case. Concatenating without normalising gives two columns + file uses upper case. Concatenating without normalizing gives two columns for one variable, so `df["LATITUDE"]` returns a DataFrame and any code building `{c.upper(): c for c in df.columns}` silently keeps one and drops the other year's values.