xtructure.io package

Submodules

xtructure.io.io module

Module for saving and loading xtructure dataclasses.

xtructure.io.io.load(path: str) Xtructurable[source]

Loads an xtructure dataclass instance from a .npz file.

This function reads the .npz file, reconstructs the dataclass type from metadata, and populates a new instance with the saved data.

Parameters:

path – The file path of the .npz file to load.

Returns:

A new instance of the saved xtructure dataclass.

xtructure.io.io.save(path: str, instance: Xtructurable)[source]

Saves an xtructure dataclass instance to a compressed .npz file.

This function serializes the instance by flattening its structure and saving each field as a NumPy array. It also stores metadata to enable reconstruction of the original dataclass type upon loading.

Parameters:
  • path – The file path (e.g., ‘/path/to/my_instance.npz’).

  • instance – The xtructure dataclass instance to save.

Module contents

Make save and load functions available for direct import from xtructure.io.

xtructure.io.load(path: str) Xtructurable[source]

Loads an xtructure dataclass instance from a .npz file.

This function reads the .npz file, reconstructs the dataclass type from metadata, and populates a new instance with the saved data.

Parameters:

path – The file path of the .npz file to load.

Returns:

A new instance of the saved xtructure dataclass.

xtructure.io.save(path: str, instance: Xtructurable)[source]

Saves an xtructure dataclass instance to a compressed .npz file.

This function serializes the instance by flattening its structure and saving each field as a NumPy array. It also stores metadata to enable reconstruction of the original dataclass type upon loading.

Parameters:
  • path – The file path (e.g., ‘/path/to/my_instance.npz’).

  • instance – The xtructure dataclass instance to save.