11.11.3 Блокноты Jupyter
Блокноты Jupyter — популярный способ комплексного представления кода, текста и графического вывода. Octave может публиковать результаты в блокнот Jupyter с помощью функции jupyter_notebook.
-
:
notebook =jupyter_notebook(notebook_filename) -
:
notebook =jupyter_notebook(notebook_filename, options) -
Запускает и заполняет блокнот Jupyter из файла notebook_filename в GNU Octave.
Поддерживается как текстовый, так и графический вывод Octave.
Этот класс имеет открытое свойство
notebook, представляющее собой структуру с декодированным из JSON блокнотом Jupyter. Это свойство намеренно сделано открытым, чтобы обеспечить расширенные возможности работы с блокнотами.Примечание: версии блокнота Jupyter (
nbformat) ниже 4.0 не поддерживаются.Необязательный второй аргумент options — это структура со следующими полями:
-
tmpdirдля задания временного рабочего каталога.
Поддерживается магическая команда
%plotсо следующими параметрами:- "
%plot -f <format>" или "%plot --format <format>": задаёт формат хранения изображений. Поддерживаются следующие форматы:- PNG (по умолчанию)
- SVG (Примечание: если изображения SVG не отображаются в блокноте, вероятнее всего, это связано с механизмами безопасности Jupyter Notebook, и потребуется явно пометить их как доверенные).
- JPG
- "
%plot -r <number>" или "%plot --resolution <number>": задаёт разрешение изображения. - "
%plot -w <number>" или "%plot --width <number>": задаёт ширину изображения. - "
%plot -h <number>" или "%plot --height <number>": задаёт высоту изображения.
Примеры:
## 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");См. также: jsondecode, jsonencode.
-
© 1996–2026 The Octave Project Developers
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://docs.octave.org/v9.4.0/Jupyter-Notebooks.html