Skip to content

Commit 7507996

Browse files
thomaspinderThomas Pinder
andauthored
Styling (#13)
* Fix docs * Fix docs * Fix docs --------- Co-authored-by: Thomas Pinder <[email protected]>
1 parent 1cbb1e1 commit 7507996

File tree

8 files changed

+99
-42
lines changed

8 files changed

+99
-42
lines changed

docs/examples/azcausal.ipynb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"\n",
5454
"linear_trend = Trend(degree=1, coefficient=0.05)\n",
5555
"data = linear_trend(simulate(cfg))\n",
56-
"plot(data)"
56+
"ax = plot(data)"
5757
]
5858
},
5959
{
@@ -76,7 +76,7 @@
7676
"TRUE_EFFECT = 0.05\n",
7777
"effect = StaticEffect(effect=TRUE_EFFECT)\n",
7878
"inflated_data = effect(data)\n",
79-
"plot(inflated_data)"
79+
"ax = plot(inflated_data)"
8080
]
8181
},
8282
{
@@ -121,14 +121,18 @@
121121
"in effort to fully stress-test any new model and identify its limitations.\n",
122122
"\n",
123123
"To achieve this, we'll simulate 10 control units, 60 pre-intervention time points, and\n",
124-
"30 post-intervention time points according to the following process: $$ \\begin{align}\n",
124+
"30 post-intervention time points according to the following process: \n",
125+
"\n",
126+
"$$ \\begin{align}\n",
125127
"\\mu_{n, t} & \\sim\\mathcal{N}(20, 0.5^2)\\\\\n",
126128
"\\alpha_{n} & \\sim \\mathcal{N}(0, 1^2)\\\\\n",
127129
"\\beta_{n} & \\sim \\mathcal{N}(0.05, 0.01^2)\\\\\n",
128130
"\\nu_n & \\sim \\mathcal{N}(1, 1^2)\\\\\n",
129131
"\\gamma_n & \\sim \\operatorname{Student-t}_{10}(1, 1^2)\\\\\n",
130132
"\\mathbf{Y}_{n, t} & = \\mu_{n, t} + \\alpha_{n} + \\beta_{n}t + \\nu_n\\sin\\left(3\\times\n",
131-
"2\\pi t + \\gamma\\right) + \\delta_{t, n} \\end{align} $$ where the true treatment effect\n",
133+
"2\\pi t + \\gamma\\right) + \\delta_{t, n} \\end{align} $$ \n",
134+
"\n",
135+
"where the true treatment effect\n",
132136
"$\\delta_{t, n}$ is 5% when $n=1$ and $t\\geq 60$ and 0 otherwise. Meanwhile,\n",
133137
"$\\mathbf{Y}$ is the matrix of observations, long in the number of time points and wide\n",
134138
"in the number of units."
@@ -159,7 +163,7 @@
159163
"periodic = Periodic(amplitude=amplitude, shift=shift, frequency=3)\n",
160164
"\n",
161165
"data = effect(periodic(linear_trend(simulate(cfg))))\n",
162-
"plot(data)"
166+
"ax = plot(data)"
163167
]
164168
},
165169
{
@@ -193,6 +197,9 @@
193197
"cell_metadata_filter": "title,-all",
194198
"main_language": "python",
195199
"notebook_metadata_filter": "-all"
200+
},
201+
"language_info": {
202+
"name": "python"
196203
}
197204
},
198205
"nbformat": 4,

docs/examples/basic.ipynb

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
")\n",
7878
"\n",
7979
"data = simulate(cfg)\n",
80-
"plot(data)"
80+
"ax = plot(data)"
8181
]
8282
},
8383
{
@@ -113,7 +113,7 @@
113113
" global_scale=s,\n",
114114
" )\n",
115115
" data = simulate(cfg)\n",
116-
" plot(data, ax=ax, title=f\"Mean: {m}, Scale: {s}\")"
116+
" _ = plot(data, ax=ax, title=f\"Mean: {m}, Scale: {s}\")"
117117
]
118118
},
119119
{
@@ -162,7 +162,7 @@
162162
"fig, axes = plt.subplots(ncols=2, figsize=(10, 3))\n",
163163
"for ax in axes:\n",
164164
" data = simulate(cfg)\n",
165-
" plot(data, ax=ax)"
165+
" _ = plot(data, ax=ax)"
166166
]
167167
},
168168
{
@@ -180,13 +180,12 @@
180180
"metadata": {},
181181
"outputs": [],
182182
"source": [
183-
"\n",
184183
"rng = np.random.RandomState(42)\n",
185184
"\n",
186185
"fig, axes = plt.subplots(ncols=2, figsize=(10, 3))\n",
187186
"for ax in axes:\n",
188187
" data = simulate(cfg, key=rng)\n",
189-
" plot(data, ax=ax)"
188+
" _ = plot(data, ax=ax)"
190189
]
191190
},
192191
{
@@ -213,8 +212,8 @@
213212
"effect = StaticEffect(effect=0.02)\n",
214213
"inflated_data = effect(data)\n",
215214
"fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(10, 3))\n",
216-
"plot(data, ax=ax0, title=\"Original data\")\n",
217-
"plot(inflated_data, ax=ax1, title=\"Inflated data\")"
215+
"ax0 = plot(data, ax=ax0, title=\"Original data\")\n",
216+
"ax1 = plot(inflated_data, ax=ax1, title=\"Inflated data\")"
218217
]
219218
},
220219
{
@@ -238,7 +237,7 @@
238237
"source": [
239238
"trend_term = Trend(degree=1, coefficient=0.1)\n",
240239
"data_with_trend = effect(trend_term(data))\n",
241-
"plot(data_with_trend)"
240+
"ax = plot(data_with_trend)"
242241
]
243242
},
244243
{
@@ -250,7 +249,7 @@
250249
"source": [
251250
"trend_term = Trend(degree=2, coefficient=0.0025)\n",
252251
"data_with_trend = effect(trend_term(data))\n",
253-
"plot(data_with_trend)"
252+
"ax = plot(data_with_trend)"
254253
]
255254
},
256255
{
@@ -270,7 +269,7 @@
270269
"source": [
271270
"periodicity = Periodic(amplitude=2, frequency=6)\n",
272271
"perioidic_data = effect(periodicity(trend_term(data)))\n",
273-
"plot(perioidic_data)"
272+
"ax = plot(perioidic_data)"
274273
]
275274
},
276275
{
@@ -292,7 +291,7 @@
292291
"intercept = UnitVaryingParameter(sampling_dist=sampling_dist)\n",
293292
"trend_term = Trend(degree=1, intercept=intercept, coefficient=0.1)\n",
294293
"data_with_trend = effect(trend_term(data))\n",
295-
"plot(data_with_trend)"
294+
"ax = plot(data_with_trend)"
296295
]
297296
},
298297
{
@@ -306,7 +305,7 @@
306305
"frequency = UnitVaryingParameter(sampling_dist=sampling_dist)\n",
307306
"\n",
308307
"p = Periodic(frequency=frequency)\n",
309-
"plot(p(data))"
308+
"ax = plot(p(data))"
310309
]
311310
},
312311
{
@@ -322,7 +321,7 @@
322321
"variation. In a follow-up notebook, we show how these datasets may be integrated with\n",
323322
"Amazon's own AZCausal library to compare the effect estimated by a model with the true\n",
324323
"effect of the underlying data generating process. A link to this notebook is\n",
325-
"[here](https://github.com/amazon-science/causal-validation/blob/main/examples/azcausal.pct.py)."
324+
"[here](http://localhost:9998/causal-validation/examples/azcausal/)."
326325
]
327326
}
328327
],
@@ -331,6 +330,9 @@
331330
"cell_metadata_filter": "title,-all",
332331
"main_language": "python",
333332
"notebook_metadata_filter": "-all"
333+
},
334+
"language_info": {
335+
"name": "python"
334336
}
335337
},
336338
"nbformat": 4,

docs/examples/placebo_test.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"TRUE_EFFECT = 0.05\n",
7474
"effect = StaticEffect(effect=TRUE_EFFECT)\n",
7575
"data = effect(simulate(cfg))\n",
76-
"plot(data)"
76+
"ax = plot(data)"
7777
]
7878
},
7979
{

docs/installation.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@
44

55
The latest stable release of `causal-validation` can be installed via `pip`:
66

7-
```bash
7+
``` bash
88
pip install causal-validation
99
```
1010

11-
!!! note "Check your installation"
12-
We recommend you check your installation version:
13-
```
14-
python -c 'import causal_validation; print(causal_validation.__version__)'
15-
```
11+
We recommend you check your installation version:
12+
13+
``` bash
14+
python -c 'import causal_validation; print(causal_validation.__version__)'
15+
```
1616

1717
## Development version
1818

1919
!!! warning
2020
This version is possibly unstable and may contain bugs.
2121

22-
The latest development version of `causal_validation` can be installed via running following:
2322

24-
```bash
25-
git clone [email protected]:amazon-science/causal-validation.git
26-
cd causal-validation
27-
hatch shell create
28-
```
23+
The latest development version of `causal_validation` can be installed via running following:
2924

30-
!!! tip
31-
We advise you create virtual environment before installing:
25+
``` bash
26+
git clone [email protected]:amazon-science/causal-validation.git;
27+
cd causal-validation;
28+
hatch shell create
29+
```
3230

33-
```bash
34-
conda create -n causal-validation python=3.11.0
35-
conda activate causal-validation
36-
```
31+
We advise you create virtual environment before installing:
32+
33+
``` bash
34+
conda create -n causal-validation python=3.11.0;
35+
conda activate causal-validation
36+
```
3737

38-
and recommend you check your installation passes the supplied unit tests:
38+
and recommend you check your installation passes the supplied unit tests:
3939

40-
```bash
41-
hatch run dev:test
42-
```
40+
``` bash
41+
hatch run dev:test
42+
```

docs/javascripts/mathjax.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
window.MathJax = {
2+
tex: {
3+
inlineMath: [["\\(", "\\)"]],
4+
displayMath: [["\\[", "\\]"]],
5+
processEscapes: true,
6+
processEnvironments: true
7+
},
8+
options: {
9+
ignoreHtmlClass: ".*|",
10+
processHtmlClass: "arithmatex"
11+
}
12+
};
13+
14+
document$.subscribe(() => {
15+
MathJax.startup.output.clearCache()
16+
MathJax.typesetClear()
17+
MathJax.texReset()
18+
MathJax.typesetPromise()
19+
})

docs/stylesheets/extra.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[data-md-color-scheme="reds"] {
2+
--md-primary-fg-color: #b5121b;
3+
--md-primary-fg-color--light: #ECB7B7;
4+
--md-primary-fg-color--dark: #7d030b;
5+
}
6+
7+
/* :root > * { */
8+
/* --md-code-bg-color: #0FF1CE; */
9+
/* } */

mkdocs.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,23 @@ theme:
2020
- navigation.sections
2121
- search.suggest
2222
- content.code.copy
23+
palette:
24+
scheme: reds
2325

2426
markdown_extensions:
2527
- abbr
2628
- admonition
29+
- pymdownx.superfences
30+
- pymdownx.inlinehilite
31+
- pymdownx.arithmatex:
32+
generic: true
33+
- pymdownx.highlight:
34+
anchor_linenums: true
35+
line_spans: __span
36+
use_pygments: true
37+
pygments_lang_class: true
38+
pygments_style: autumn
39+
noclasses: true
2740

2841
plugins:
2942
- search
@@ -35,5 +48,12 @@ extra:
3548
version:
3649
provider: mike
3750

51+
extra_css:
52+
- stylesheets/extra.css
53+
54+
extra_javascript:
55+
- javascripts/mathjax.js
56+
- https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js
57+
3858
watch:
3959
- src

src/causal_validation/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "0.0.5"
1+
__version__ = "0.0.6"
22

33
__all__ = ["__version__"]

0 commit comments

Comments
 (0)