-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4421605
commit a064ad3
Showing
10 changed files
with
110 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
"""Prelude Runner.""" | ||
from .core import Preludes, execute | ||
|
||
__all__ = ["execute", "Preludes"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,60 @@ | ||
"""Types more specific than NotebookNode.""" | ||
from __future__ import annotations | ||
|
||
from typing import Any, Literal, Protocol, TypedDict | ||
|
||
|
||
class CellMetadata(TypedDict): | ||
"""Common metadata for all cells.""" | ||
|
||
tags: list[str] | ||
|
||
|
||
class Cell(Protocol): | ||
"""A cell in a notebook.""" | ||
|
||
cell_type: Literal["markdown", "code"] | ||
metadata: CellMetadata | ||
source: str | ||
|
||
|
||
class Output(Protocol): | ||
"""A code cell’s output.""" | ||
|
||
output_type: Literal[ | ||
"stream", "display_data", "execute_result", "error", "update_display_data" | ||
"stream", | ||
"display_data", | ||
"execute_result", | ||
"error", | ||
"update_display_data", | ||
] | ||
data: dict[str, str] | ||
|
||
|
||
class Stream(Protocol): | ||
"""One type of output from a code cell.""" | ||
|
||
output_type: Literal["stream"] | ||
name: Literal["stdout", "stderr"] | ||
text: str | ||
|
||
|
||
class CodeCell(Cell): | ||
"""A code cell.""" | ||
|
||
cell_type: Literal["code"] | ||
outputs: list[Stream | Any] # TODO | ||
# TODO: add other output types # noqa: TD003 | ||
outputs: list[Stream | Any] | ||
|
||
|
||
class NotebookMetadata(TypedDict): | ||
"""Common metadata for all notebooks.""" | ||
|
||
language_info: dict[str, str] | ||
|
||
|
||
class Notebook(Protocol): | ||
"""A Jupyter notebook.""" | ||
|
||
metadata: NotebookMetadata | ||
cells: list[Cell] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import random | ||
from contextlib import suppress | ||
|
||
random.seed(0) | ||
|
||
with suppress(Exception): | ||
from numpy.random import seed | ||
|
||
seed(0) # noqa: NPY002 |
File renamed without changes.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters