load_dataclass_npz#
Class method.
- do_dpc.utils.serialization.load_dataclass_npz(cls, filename)[source]#
Loads a dataclass object from a .npz file, reconstructing NumPy arrays, floats, and integers.
- Parameters:
cls (Type[T]) – The class type of the dataclass to reconstruct.
filename (str) – The .npz file path from which the object should be loaded.
- Returns:
The reconstructed dataclass object.
- Return type:
T
- Raises:
FileNotFoundError – If the specified file does not exist.
ValueError – If the loaded data contains unsupported types or is incompatible with the dataclass.
Note
Converts 0D NumPy arrays (e.g., np.array(0.1)) back to Python scalars (float or int).
Only fields that exist in the dataclass definition are reconstructed.
If a field is missing in the .npz file, it will raise a TypeError (from dataclass instantiation).