Skip to content

Commit

Permalink
Merge branch 'master' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz authored Sep 19, 2024
2 parents 0498005 + 25fa81d commit c1c6306
Show file tree
Hide file tree
Showing 9 changed files with 320 additions and 7 deletions.
10 changes: 8 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
groups:
actions:
patterns:
- "*"
labels:
- "github_actions"
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:

# TEMPORARY FIX: Disable codecov until we can get it working again
- name: Upload to Codecov
uses: codecov/codecov-action@v3.1.4
uses: codecov/codecov-action@v4
if: false
with:
name: myst-nb-pytests
Expand Down
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ exclude: >
tests/.*\.txt
)$
ci:
autoupdate_schedule: 'monthly'

repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,66 @@
# Change Log

## v1.1.1 - 2024-06-27

([full changelog](https://github.com/executablebooks/MyST-NB/compare/v1.1.0...6ce30cd41fa82543e0f315ac8bbee82669b0cc82))

### Bugs fixed

- FIX: output metadata overwrites image size for all following images [#609](https://github.com/executablebooks/MyST-NB/pull/609) ([@aeisenbarth](https://github.com/aeisenbarth))

- FIX: remove incorrect license classifier [#603](https://github.com/executablebooks/MyST-NB/pull/603) ([@agoose77](https://github.com/agoose77))

### Maintenance and upkeep improvements

- MAINT: bump version [#614](https://github.com/executablebooks/MyST-NB/pull/614) ([@agoose77](https://github.com/agoose77))

- MAINT: appease mypy [#612](https://github.com/executablebooks/MyST-NB/pull/612) ([@agoose77](https://github.com/agoose77))

- MAINT: fix specs for CI matrix [#611](https://github.com/executablebooks/MyST-NB/pull/611) ([@agoose77](https://github.com/agoose77))

- MAINT: bump version [#592](https://github.com/executablebooks/MyST-NB/pull/592) ([@agoose77](https://github.com/agoose77))

### Documentation improvements

- DOCS: set printoptions to disable modern scalar printing [#613](https://github.com/executablebooks/MyST-NB/pull/613) ([@agoose77](https://github.com/agoose77))

- DOCS: extra comma forgotten [#606](https://github.com/executablebooks/MyST-NB/pull/606) ([@jeertmans](https://github.com/jeertmans))

- DOCS: update shown code to match source [#598](https://github.com/executablebooks/MyST-NB/pull/598) ([@OriolAbril](https://github.com/OriolAbril))

### Contributors to this release

([GitHub contributors page for this release](https://github.com/executablebooks/MyST-NB/graphs/contributors?from=2024-04-12&to=2024-06-27&type=c))

[@aeisenbarth](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Aaeisenbarth+updated%3A2024-04-12..2024-06-27&type=Issues) | [@agoose77](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Aagoose77+updated%3A2024-04-12..2024-06-27&type=Issues) | [@jeertmans](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Ajeertmans+updated%3A2024-04-12..2024-06-27&type=Issues) | [@OriolAbril](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3AOriolAbril+updated%3A2024-04-12..2024-06-27&type=Issues) | [@sstroemer](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Asstroemer+updated%3A2024-04-12..2024-06-27&type=Issues) | [@welcome](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Awelcome+updated%3A2024-04-12..2024-06-27&type=Issues)


## v1.1.0 - 2024-04-12

([full changelog](https://github.com/executablebooks/MyST-NB/compare/v1.0.0...9943ec214c35844c4535d0184f7840574fc7ab03))

### Enhancements made

- ENH: pass-through image metadata [#588](https://github.com/executablebooks/MyST-NB/pull/588) ([@flying-sheep](https://github.com/flying-sheep))

### Maintenance and upkeep improvements

- MAINT: bump version [#592](https://github.com/executablebooks/MyST-NB/pull/592) ([@agoose77](https://github.com/agoose77))

- MAINT: use `findall` instead of `traverse` [#585](https://github.com/executablebooks/MyST-NB/pull/585) ([@agoose77](https://github.com/agoose77))

- MAINT: restore default line length [#577](https://github.com/executablebooks/MyST-NB/pull/577) ([@agoose77](https://github.com/agoose77))

### Other merged PRs

- build(deps): bump actions/setup-python from 4 to 5 [#576](https://github.com/executablebooks/MyST-NB/pull/576) ([@dependabot](https://github.com/dependabot))

### Contributors to this release

([GitHub contributors page for this release](https://github.com/executablebooks/MyST-NB/graphs/contributors?from=2023-11-08&to=2024-04-12&type=c))

[@agoose77](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Aagoose77+updated%3A2023-11-08..2024-04-12&type=Issues) | [@cisaacstern](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Acisaacstern+updated%3A2023-11-08..2024-04-12&type=Issues) | [@dependabot](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Adependabot+updated%3A2023-11-08..2024-04-12&type=Issues) | [@flying-sheep](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Aflying-sheep+updated%3A2023-11-08..2024-04-12&type=Issues) | [@ma-sadeghi](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Ama-sadeghi+updated%3A2023-11-08..2024-04-12&type=Issues) | [@peytondmurray](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Apeytondmurray+updated%3A2023-11-08..2024-04-12&type=Issues) | [@PhilipVinc](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3APhilipVinc+updated%3A2023-11-08..2024-04-12&type=Issues) | [@sphuber](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Asphuber+updated%3A2023-11-08..2024-04-12&type=Issues) | [@welcome](https://github.com/search?q=repo%3Aexecutablebooks%2FMyST-NB+involves%3Awelcome+updated%3A2023-11-08..2024-04-12&type=Issues)


## v1.0.0 - 2023-11-08

Expand Down
27 changes: 24 additions & 3 deletions docs/render/glue.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To glue keys from other notebooks, see {ref}`glue/crossdoc`.
## Save variables in code cells

You can use `myst_nb.glue()` to assign the output of a variable to a key of your choice.
`glue` will store all of the information that is normally used to display that variable (ie, whatever happens when you display the variable by putting it at the end of a cell).
`glue` will store all of the information that is normally used to display that variable (that is, whatever happens when you display the variable by putting it at the end of a cell).
Choose a key that you will remember, as you will use it later.

The following code glues a variable inside the notebook:
Expand Down Expand Up @@ -137,12 +137,12 @@ These variables can be pasted using one of the roles or directives in the `glue:

### The `glue` role/directive

The simplest role and directive are `glue` (a.k.a. `glue:any`),
The simplest role and directive are `glue` (also known as `glue:any`),
which paste the glued output inline or as a block respectively,
with no additional formatting.
Simply add:

````
````md
```{glue} your-key
```
````
Expand Down Expand Up @@ -219,6 +219,27 @@ For example, the following: ``My rounded mean: {glue:text}`boot_mean:.2f` `` wil

My rounded mean: {glue:text}`boot_mean:.2f` (95% CI: {glue:text}`boot_clo:.2f`/{glue:text}`boot_chi:.2f`).

````{warning}
As of NumPy 2.0, the `text/plain` representation of [NumPy objects has changed](https://numpy.org/devdocs/release/2.0.0-notes.html#representation-of-numpy-scalars-changed).
Using text formatting with NumPy>=2.0 will give warnings like:
```
sphinx.errors.SphinxWarning: <filename>:257:Failed to format text/plain data: could not convert string to float: 'np.float64(0.9643970836113095)' [mystnb.glue]
```
This can be resolved by either formatting the number before glueing or by setting NumPy to use legacy print options, as shown below.
```python
var = np.float(1.0)
# Format the variable before glueing
glue("var_glue", f"{var:.2f}")
# Or set NumPy legacy print options
np.setprintoptions(legacy="1.25")
glue("var_glue", var)
```
````

+++

### The `glue:figure` directive
Expand Down
5 changes: 4 additions & 1 deletion myst_nb/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ def coalesce_streams(outputs: list[NotebookNode]) -> list[NotebookNode]:
for output in outputs:
if output["output_type"] == "stream":
if output["name"] in streams:
streams[output["name"]]["text"] += output["text"]
out = output["text"].strip()
if out:
streams[output["name"]]["text"] += f"{out}\n"
else:
output["text"] = output["text"].strip() + "\n"
new_outputs.append(output)
streams[output["name"]] = output
else:
Expand Down
186 changes: 186 additions & 0 deletions tests/notebooks/merge_streams_parallel.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2024-09-19T21:44:29.809012Z",
"iopub.status.busy": "2024-09-19T21:44:29.808809Z",
"iopub.status.idle": "2024-09-19T21:44:29.978481Z",
"shell.execute_reply": "2024-09-19T21:44:29.977891Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"from concurrent.futures import ProcessPoolExecutor\n",
"\n",
"with ProcessPoolExecutor() as executor:\n",
" for i in executor.map(print, [0] * 10):\n",
" pass"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
12 changes: 12 additions & 0 deletions tests/test_render_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ def test_merge_streams(sphinx_run, file_regression):
file_regression.check(doctree.pformat(), extension=".xml", encoding="utf-8")


@pytest.mark.sphinx_params(
"merge_streams_parallel.ipynb",
conf={"nb_execution_mode": "off", "nb_merge_streams": True},
)
def test_merge_streams_parallel(sphinx_run, file_regression):
"""Test configuring multiple concurrent stdout/stderr outputs to be merged."""
sphinx_run.build()
assert sphinx_run.warnings() == ""
doctree = sphinx_run.get_resolved_doctree("merge_streams_parallel")
file_regression.check(doctree.pformat(), extension=".xml", encoding="utf-8")


@pytest.mark.sphinx_params(
"metadata_image.ipynb",
conf={"nb_execution_mode": "off", "nb_cell_metadata_key": "myst"},
Expand Down
21 changes: 21 additions & 0 deletions tests/test_render_outputs/test_merge_streams_parallel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<document source="merge_streams_parallel">
<container cell_index="0" cell_metadata="{'execution': {'iopub.execute_input': '2024-09-19T21:44:29.809012Z', 'iopub.status.busy': '2024-09-19T21:44:29.808809Z', 'iopub.status.idle': '2024-09-19T21:44:29.978481Z', 'shell.execute_reply': '2024-09-19T21:44:29.977891Z'}}" classes="cell" exec_count="1" nb_element="cell_code">
<container classes="cell_input" nb_element="cell_code_source">
<literal_block language="ipython3" linenos="False" xml:space="preserve">
from concurrent.futures import ProcessPoolExecutor

with ProcessPoolExecutor() as executor:
for i in executor.map(print, [0] * 10):
pass
<container classes="cell_output" nb_element="cell_code_output">
<literal_block classes="output stream" language="myst-ansi" linenos="False" xml:space="preserve">
0
0
0
0
0
0
0
0
0
0

0 comments on commit c1c6306

Please sign in to comment.