Skip to content

Strange spaces in output depending on execution time. #664

@mforbes

Description

@mforbes

Describe the bug

context
When I execute the following code cell...

```{code-cell}
import time
for n in range(10):
    print(n)
    time.sleep(0.02*n)
```

expectation
I expected to get continuous output in a single output block.

bug
But instead, I get spaces between outputs that depend on how long the cell executes:

Image

problem
This is a minor problem, but significantly degrades the output experience.

Notes:

  • This does not happen with mystmd execution.
  • It is possible this is an upstream issue, but I don't yet know enough about how myst-nb processes code to trace this.

Reproduce the bug

  1. Insert the following code cell into a jupyter book. (I just added this to mynewbook/markdown-notebook.md after following the quickstart tutorial:
```{code-cell}
import time
for n in range(10):
    print(n)
    time.sleep(0.02*n)
```

Complete Instructions

python3 -m venv env
./env/bin/python3 -m pip install --upgrade pip jupyter-book
bash --init-file <(echo ". ./env/bin/activate")
jupyter-book create mynewbook
emacs mynewbook/markdown-notebook.md   # Add code cell
jupyter-book build mynewbook
exit
open mynewbook/_build/html/markdown-notebooks.html 

List your environment

$ python --version
Python 3.10.10
$ jupyter-book --version      
Jupyter Book      : 1.0.3
External ToC      : 1.0.1
MyST-Parser       : 2.0.0
MyST-NB           : 1.2.0
Sphinx Book Theme : 1.1.3
Jupyter-Cache     : 1.0.1
NbClient          : 0.10.2
$ uname -a
Darwin Admins-MacBook-Pro-2.local 23.6.0 Darwin Kernel Version 23.6.0: Fri Nov 15 15:13:15 PST 2024; root:xnu-10063.141.1.702.7~1/RELEASE_ARM64_T6000 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions