Skip to content

Commit

Permalink
Make the generated documentation more reproducible (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitya57 authored Dec 23, 2024
1 parent 4a1a590 commit b363e5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/content/notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ See [the Pandas Styling docs](https://pandas.pydata.org/pandas-docs/stable/user_
:tags: [hide-input]
import pandas as pd
from pandas.io.formats.style import Styler
np.random.seed(24)
df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
Expand All @@ -195,8 +196,8 @@ def highlight_max(s):
is_max = s == s.max()
return ['background-color: yellow' if v else '' for v in is_max]
df.style.\
applymap(color_negative_red).\
Styler(df, uuid="1").\
map(color_negative_red).\
apply(highlight_max).\
set_table_attributes('style="font-size: 10px"')
```
Expand Down
11 changes: 9 additions & 2 deletions docs/reference/notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ It also has a `thebe-init` tag which means it will be executed when you initiali
# Generate some code that we'll use later on in the page
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(0)
```

### Hide inputs
Expand All @@ -45,6 +47,7 @@ ax.imshow(square)
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

### Hide outputs
Expand All @@ -61,6 +64,7 @@ ax.imshow(square)
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

### Hide markdown
Expand Down Expand Up @@ -93,6 +97,7 @@ ax.imshow(square)
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

### Hide the whole cell
Expand All @@ -108,6 +113,7 @@ ax.imshow(square)
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

## Enriched outputs
Expand Down Expand Up @@ -136,6 +142,7 @@ Styled DataFrames (see [the Pandas Styling docs](https://pandas.pydata.org/panda
:tags: [hide-input]
import pandas as pd
from pandas.io.formats.style import Styler
np.random.seed(24)
df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
Expand All @@ -160,8 +167,8 @@ def highlight_max(s):
is_max = s == s.max()
return ['background-color: yellow' if v else '' for v in is_max]
df.style.\
applymap(color_negative_red).\
Styler(df, uuid="1").\
map(color_negative_red).\
apply(highlight_max).\
set_table_attributes('style="font-size: 10px"')
```
Expand Down
6 changes: 6 additions & 0 deletions docs/reference/special-theme-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ through and see how things look!
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(0)
square = np.random.randn(100, 100)
wide = np.random.randn(100, 1000)
```
Expand All @@ -41,6 +43,7 @@ wide = np.random.randn(100, 1000)
## A full-width square figure
fig, ax = plt.subplots()
ax.imshow(square)
plt.show()
```

```{code-cell} ipython3
Expand All @@ -49,12 +52,14 @@ ax.imshow(square)
## A full-width wide figure
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

```{code-cell} ipython3
# Now here's the same figure at regular width
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

### Markdown
Expand Down Expand Up @@ -194,6 +199,7 @@ Let's see what happens
## code cell in the margin with output
fig, ax = plt.subplots()
ax.imshow(wide)
plt.show()
```

````{margin}
Expand Down

0 comments on commit b363e5f

Please sign in to comment.