11.11.3 Jupyter ノートブック
Jupyter ノートブックは、コード、テキスト、グラフィカル出力を包括的にまとめて表示するための一般的な手法の 1 つです。Octave は、jupyter_notebook関数を使用して結果を Jupyter ノートブックに公開できます。
: notebook = jupyter_notebook (notebook_filename)
: notebook = jupyter_notebook (notebook_filename, options)
GNU Octave 内から Jupyter Notebook を実行し、ファイルnotebook_filenameにデータを入力します。
テキストとグラフィカルの両方の Octave 出力がサポートされています。
notebookこのクラスには、JSON でデコードされた Jupyter Notebook を表す構造である パブリック プロパティがあります。このプロパティは、高度なノートブック操作を可能にするために意図的にパブリックになっています。
注意: Jupyter Notebook バージョン ( nbformat) 4.0 未満はサポートされていません。
オプションの 2 番目の引数options は、次のフィールドを持つ構造体です。
tmpdir to set the temporary working directory.
%plotmagic は次の設定でサポートされます:
"%plot -f <format>" or "%plot --format <format>": specifies the image storage format. Supported formats are: PNG (default) SVG (Note: If SVG images do not appear in the notebook, it is most likely related to Jupyter Notebook security mechanisms and explicitly "trusting" them will be necessary). JPG "%plot -r <number>" or "%plot --resolution <number>": specifies the image resolution. "%plot -w <number>" or "%plot --width <number>": specifies the image width. "%plot -h <number>" or "%plot --height <number>": specifies the image height.
Examples:
## Run all cells and generate the filled notebook
## Instantiate an object from a notebook file
notebook = jupyter_notebook ("myNotebook.ipynb");
## Run the code and embed the results in the notebook property
notebook.run_all ();
## Generate a new notebook by overwriting the original notebook
notebook.generate_notebook ("myNotebook.ipynb");
## Run just the second cell and generate the filled notebook
## Instantiate an object from a notebook file
notebook = jupyter_notebook ("myNotebook.ipynb");
## Run the code and embed the results in the notebook property
notebook.run (2)
## Generate a new notebook in a new file
notebook.generate_notebook ("myNewNotebook.ipynb");
## Generate an Octave script from a notebook
## Instantiate an object from a notebook file
notebook = jupyter_notebook ("myNotebook.ipynb");
## Generate the Octave script
notebook.generate_octave_script ("jup_script.m");
See also: jsondecode, jsonencode.