Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Notebooks

%load_ext shapescript adds the %%shapescript cell magic to Jupyter and VS Code notebooks. A cell is a file that may also have statements outside any fn.

Each cell is checked together with the cells that have run without errors, in the order they last ran: declarations are hoisted as in a module, a name declared in several cells has the latest cell’s declaration, and statements outside any fn are checked in order, in one scope. A for or if outside any fn follows the block rules within its cell; a later cell sees the values first bound in the block as Python values. Python variables of the notebook are visible as Python values where nothing else has the name. A cell with errors shows them as its output and runs nothing; a cell that ends with a tensor shows its shape diagram.

What a cell made can’t be used once it doesn’t match the cell’s code any more, until the cell runs again (E0701): what a cell defines when the cell no longer checks, a value whose type isn’t the one it was made with (as after its dims changed, including a model whose fields’ shapes changed), a declaration that Python code has assigned or deleted, and functions, domains and models that use any of those.