Commit 711970c
Clean up experiments/: typos, annotations, and constants (#796)
* Fix typos in diff_in_diff and prepostnegd
- diff_in_diff.py: "treament" -> "treatment" in plot label
- prepostnegd.py: "trestment" -> "treatment" in comment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix **kwargs: dict -> **kwargs: Any in experiment __init__ and plot methods
`**kwargs: dict` is incorrect — it annotates each value as a dict,
not the collection. Every experiment except inverse_propensity_weighting
(which already used Any) is fixed.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Replace `is False` with `not` for dummy-coded checks
Use idiomatic `if not func(...)` instead of `if func(...) is False`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Move misplaced docstring in DifferenceInDifferences.input_validation
The docstring was after the first executable line; move it to the
correct position immediately after the method signature.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Standardize expt_type to instance attribute in ITS and PiecewiseITS
- interrupted_time_series.py: remove dead class attribute (overwritten
by self.expt_type in __init__)
- piecewise_its.py: move class attribute to self.expt_type in __init__
- Update test to check expt_type as instance attribute
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Extract LEGEND_FONT_SIZE to experiments/constants.py
Create a shared constants module and replace the per-file
`LEGEND_FONT_SIZE = 12` definitions in all 8 experiment files with
an import from `causalpy.experiments.constants`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Extract HDI_PROB constant to utils.py and use throughout
Add `HDI_PROB: float = 0.94` to `causalpy/utils.py` and replace all
hardcoded `0.94` parameter defaults and `0.03` / `1 - 0.03` quantile
bounds with expressions derived from HDI_PROB.
Updated files: utils.py, plot_utils.py, pymc_models.py, and 6
experiment modules (prepostnegd, regression_discontinuity,
regression_kink, interrupted_time_series, piecewise_its,
staggered_did, synthetic_control).
Test files and docstrings are intentionally left unchanged.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix ruff linting: import ordering, HDI_PROB placement, line length, and UP038
- Move HDI_PROB after all imports in utils.py to avoid E402
- Sort `from causalpy.experiments.constants` alphabetically with other causalpy imports
- Wrap long quantile lines for ruff format compliance
- Fix pre-existing UP038: use `X | Y` instead of `(X, Y)` in isinstance
- Restore `from typing import Any, Literal` in regression_discontinuity.py
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Move HDI_PROB and LEGEND_FONT_SIZE to causalpy/constants.py and derive CI labels from HDI_PROB
- Create causalpy/constants.py as single home for shared constants
- Delete causalpy/experiments/constants.py (now unused)
- Update all imports across 10 files to use causalpy.constants directly
- Fix 5 hardcoded "94%" label strings to derive from HDI_PROB (pymc_models,
utils, regression_kink, regression_discontinuity, prepostnegd); also fix
missing backslash before % in prepostnegd CI string
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Fix ruff formatting: add spaces around * in HDI_PROB f-strings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Remove hardcoded '94%' from docstrings and comments
These strings should not reference a specific percentage since
the actual interval width is derived from HDI_PROB at runtime.
Made-with: Cursor
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Benjamin T. Vincent <inferencelab@gmail.com>1 parent 57efa72 commit 711970c
14 files changed
Lines changed: 104 additions & 78 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
52 | | - | |
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
| |||
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | | - | |
| 109 | + | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
| |||
261 | 260 | | |
262 | 261 | | |
263 | 262 | | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
267 | | - | |
268 | 266 | | |
269 | 267 | | |
270 | 268 | | |
| |||
282 | 280 | | |
283 | 281 | | |
284 | 282 | | |
285 | | - | |
| 283 | + | |
286 | 284 | | |
287 | 285 | | |
288 | 286 | | |
| |||
331 | 329 | | |
332 | 330 | | |
333 | 331 | | |
334 | | - | |
| 332 | + | |
335 | 333 | | |
336 | 334 | | |
337 | 335 | | |
338 | | - | |
| 336 | + | |
339 | 337 | | |
340 | 338 | | |
341 | 339 | | |
| |||
485 | 483 | | |
486 | 484 | | |
487 | 485 | | |
488 | | - | |
| 486 | + | |
489 | 487 | | |
490 | 488 | | |
491 | 489 | | |
| |||
517 | 515 | | |
518 | 516 | | |
519 | 517 | | |
520 | | - | |
| 518 | + | |
521 | 519 | | |
522 | 520 | | |
523 | 521 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
38 | | - | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
129 | | - | |
130 | 128 | | |
131 | 129 | | |
132 | 130 | | |
| |||
138 | 136 | | |
139 | 137 | | |
140 | 138 | | |
141 | | - | |
| 139 | + | |
142 | 140 | | |
143 | 141 | | |
144 | 142 | | |
| |||
227 | 225 | | |
228 | 226 | | |
229 | 227 | | |
230 | | - | |
| 228 | + | |
231 | 229 | | |
232 | 230 | | |
233 | 231 | | |
| |||
601 | 599 | | |
602 | 600 | | |
603 | 601 | | |
604 | | - | |
| 602 | + | |
605 | 603 | | |
606 | 604 | | |
607 | 605 | | |
| |||
797 | 795 | | |
798 | 796 | | |
799 | 797 | | |
800 | | - | |
| 798 | + | |
801 | 799 | | |
802 | 800 | | |
803 | 801 | | |
| |||
887 | 885 | | |
888 | 886 | | |
889 | 887 | | |
890 | | - | |
| 888 | + | |
891 | 889 | | |
892 | 890 | | |
893 | 891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
147 | | - | |
148 | 146 | | |
149 | 147 | | |
150 | 148 | | |
| |||
154 | 152 | | |
155 | 153 | | |
156 | 154 | | |
157 | | - | |
| 155 | + | |
158 | 156 | | |
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
| 160 | + | |
162 | 161 | | |
163 | 162 | | |
164 | 163 | | |
| |||
446 | 445 | | |
447 | 446 | | |
448 | 447 | | |
449 | | - | |
| 448 | + | |
450 | 449 | | |
451 | 450 | | |
452 | 451 | | |
| |||
563 | 562 | | |
564 | 563 | | |
565 | 564 | | |
566 | | - | |
| 565 | + | |
567 | 566 | | |
568 | 567 | | |
569 | 568 | | |
| |||
626 | 625 | | |
627 | 626 | | |
628 | 627 | | |
629 | | - | |
| 628 | + | |
630 | 629 | | |
631 | 630 | | |
632 | 631 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
100 | | - | |
| 99 | + | |
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
| |||
184 | 183 | | |
185 | 184 | | |
186 | 185 | | |
187 | | - | |
| 186 | + | |
188 | 187 | | |
189 | 188 | | |
190 | 189 | | |
| |||
213 | 212 | | |
214 | 213 | | |
215 | 214 | | |
216 | | - | |
217 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
218 | 219 | | |
219 | | - | |
| 220 | + | |
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
| |||
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
238 | | - | |
| 239 | + | |
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 35 | | |
38 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | | - | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
104 | | - | |
| 106 | + | |
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
| |||
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
247 | | - | |
| 249 | + | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
| |||
296 | 298 | | |
297 | 299 | | |
298 | 300 | | |
299 | | - | |
| 301 | + | |
300 | 302 | | |
301 | 303 | | |
302 | 304 | | |
| |||
333 | 335 | | |
334 | 336 | | |
335 | 337 | | |
336 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
337 | 341 | | |
338 | | - | |
| 342 | + | |
339 | 343 | | |
340 | 344 | | |
341 | 345 | | |
| |||
372 | 376 | | |
373 | 377 | | |
374 | 378 | | |
375 | | - | |
| 379 | + | |
376 | 380 | | |
377 | 381 | | |
378 | 382 | | |
| |||
0 commit comments