aerosandbox.tools.python#

Submodules#

Package Contents#

Functions#

convert_ipynb_to_py(input_file, output_file)

Reads an input Jupyter notebook (.ipynb) and converts it to a Python file (.py)

convert_ipynb_to_py(input_file, output_file)

Reads an input Jupyter notebook (.ipynb) and converts it to a Python file (.py)

run_python_file(path)

Executes a Python file from a path.

run_all_python_files(path[, recursive, verbose])

Executes all Python files and Jupyter Notebooks in a directory.

lazy_import(name)

Allows you to lazily import a module.

aerosandbox.tools.python.convert_ipynb_to_py(input_file, output_file)[source]#

Reads an input Jupyter notebook (.ipynb) and converts it to a Python file (.py)

Tried using jupyter nbconvert, but that is SO SLOW, like 3 seconds per notebook! It’s just json parsing, this should not take more than a few milliseconds - come on, Jupyter!

Parameters:
  • input_file (pathlib.Path) – File path

  • output_file (pathlib.Path) – File path

Return type:

None

Returns: None

aerosandbox.tools.python.convert_ipynb_to_py(input_file, output_file)[source]#

Reads an input Jupyter notebook (.ipynb) and converts it to a Python file (.py)

Tried using jupyter nbconvert, but that is SO SLOW, like 3 seconds per notebook! It’s just json parsing, this should not take more than a few milliseconds - come on, Jupyter!

Parameters:
  • input_file (pathlib.Path) – File path

  • output_file (pathlib.Path) – File path

Return type:

None

Returns: None

aerosandbox.tools.python.run_python_file(path)[source]#

Executes a Python file from a path. :param path: File path

Returns: None

Parameters:

path (pathlib.Path) –

Return type:

None

aerosandbox.tools.python.run_all_python_files(path, recursive=True, verbose=True)[source]#

Executes all Python files and Jupyter Notebooks in a directory. :param path: A Path-type object (Path from built-in pathlib) representing a filepath :param recursive: Executes recursively (e.g. searches all subfolders too)

Returns: None

Parameters:

path (pathlib.Path) –

Return type:

None

aerosandbox.tools.python.lazy_import(name)[source]#

Allows you to lazily import a module.

Usage: >>> asb = lazy_import(“aerosandbox”) # Runs instantly >>> asb.Airplane() # When this is called, ASB will be loaded.

Parameters:

name – The package name

Returns: The module itself, to be loaded on first use.