Skip to content

Commit b363e5f

Browse files
authored
Make the generated documentation more reproducible (#883)
1 parent 4a1a590 commit b363e5f

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

docs/content/notebooks.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ See [the Pandas Styling docs](https://pandas.pydata.org/pandas-docs/stable/user_
171171
:tags: [hide-input]
172172
173173
import pandas as pd
174+
from pandas.io.formats.style import Styler
174175
175176
np.random.seed(24)
176177
df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
@@ -195,8 +196,8 @@ def highlight_max(s):
195196
is_max = s == s.max()
196197
return ['background-color: yellow' if v else '' for v in is_max]
197198
198-
df.style.\
199-
applymap(color_negative_red).\
199+
Styler(df, uuid="1").\
200+
map(color_negative_red).\
200201
apply(highlight_max).\
201202
set_table_attributes('style="font-size: 10px"')
202203
```

docs/reference/notebooks.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ It also has a `thebe-init` tag which means it will be executed when you initiali
2929
# Generate some code that we'll use later on in the page
3030
import numpy as np
3131
import matplotlib.pyplot as plt
32+
33+
np.random.seed(0)
3234
```
3335

3436
### Hide inputs
@@ -45,6 +47,7 @@ ax.imshow(square)
4547
4648
fig, ax = plt.subplots()
4749
ax.imshow(wide)
50+
plt.show()
4851
```
4952

5053
### Hide outputs
@@ -61,6 +64,7 @@ ax.imshow(square)
6164
6265
fig, ax = plt.subplots()
6366
ax.imshow(wide)
67+
plt.show()
6468
```
6569

6670
### Hide markdown
@@ -93,6 +97,7 @@ ax.imshow(square)
9397
9498
fig, ax = plt.subplots()
9599
ax.imshow(wide)
100+
plt.show()
96101
```
97102

98103
### Hide the whole cell
@@ -108,6 +113,7 @@ ax.imshow(square)
108113
109114
fig, ax = plt.subplots()
110115
ax.imshow(wide)
116+
plt.show()
111117
```
112118

113119
## Enriched outputs
@@ -136,6 +142,7 @@ Styled DataFrames (see [the Pandas Styling docs](https://pandas.pydata.org/panda
136142
:tags: [hide-input]
137143
138144
import pandas as pd
145+
from pandas.io.formats.style import Styler
139146
140147
np.random.seed(24)
141148
df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
@@ -160,8 +167,8 @@ def highlight_max(s):
160167
is_max = s == s.max()
161168
return ['background-color: yellow' if v else '' for v in is_max]
162169
163-
df.style.\
164-
applymap(color_negative_red).\
170+
Styler(df, uuid="1").\
171+
map(color_negative_red).\
165172
apply(highlight_max).\
166173
set_table_attributes('style="font-size: 10px"')
167174
```

docs/reference/special-theme-elements.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ through and see how things look!
3131
import numpy as np
3232
import matplotlib.pyplot as plt
3333
34+
np.random.seed(0)
35+
3436
square = np.random.randn(100, 100)
3537
wide = np.random.randn(100, 1000)
3638
```
@@ -41,6 +43,7 @@ wide = np.random.randn(100, 1000)
4143
## A full-width square figure
4244
fig, ax = plt.subplots()
4345
ax.imshow(square)
46+
plt.show()
4447
```
4548

4649
```{code-cell} ipython3
@@ -49,12 +52,14 @@ ax.imshow(square)
4952
## A full-width wide figure
5053
fig, ax = plt.subplots()
5154
ax.imshow(wide)
55+
plt.show()
5256
```
5357

5458
```{code-cell} ipython3
5559
# Now here's the same figure at regular width
5660
fig, ax = plt.subplots()
5761
ax.imshow(wide)
62+
plt.show()
5863
```
5964

6065
### Markdown
@@ -194,6 +199,7 @@ Let's see what happens
194199
## code cell in the margin with output
195200
fig, ax = plt.subplots()
196201
ax.imshow(wide)
202+
plt.show()
197203
```
198204

199205
````{margin}

0 commit comments

Comments
 (0)