Record Class JupyterNotebook

java.lang.Object
java.lang.Record
smile.util.ipynb.JupyterNotebook
Record Components:
cells - the list of cells in document order.
metadata - the notebook-level metadata.
nbformat - the major version of the notebook format (5).
nbformatMinor - the minor version of the notebook format.

public record JupyterNotebook(List<Cell> cells, Metadata metadata, int nbformat, int nbformatMinor) extends Record
The top-level Jupyter notebook document (nbformat 5).

A notebook document consists of an ordered list of cells, metadata about the notebook, and version information. The current major version is 5 with the minor version indicating incremental additions (e.g. 5.4 added the cell id field as a required property).

See Also:
  • Field Details

    • NBFORMAT

      public static final int NBFORMAT
      The current (latest) major format version.
      See Also:
    • NBFORMAT_MINOR

      public static final int NBFORMAT_MINOR
      The current (latest) minor format version.
      See Also:
  • Constructor Details

    • JupyterNotebook

      public JupyterNotebook(List<Cell> cells, Metadata metadata, int nbformat, int nbformatMinor)
      Creates an instance of a JupyterNotebook record class.
      Parameters:
      cells - the value for the cells record component
      metadata - the value for the metadata record component
      nbformat - the value for the nbformat record component
      nbformatMinor - the value for the nbformatMinor record component
  • Method Details

    • from

      public static JupyterNotebook from(Path path) throws IOException
      Reads a notebook file.
      Parameters:
      path - the path to the notebook file.
      Returns:
      the notebook read from the specified path.
      Throws:
      IOException - when fails to read the file.
    • write

      public void write(Path path) throws IOException
      Writes the notebook to the specified file.
      Parameters:
      path - the file path to write the notebook to.
      Throws:
      IOException - when fails to write the file.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • cells

      public List<Cell> cells()
      Returns the value of the cells record component.
      Returns:
      the value of the cells record component
    • metadata

      public Metadata metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component
    • nbformat

      public int nbformat()
      Returns the value of the nbformat record component.
      Returns:
      the value of the nbformat record component
    • nbformatMinor

      public int nbformatMinor()
      Returns the value of the nbformatMinor record component.
      Returns:
      the value of the nbformatMinor record component