torchsig.utils.file_handlers.zarr.ZarrFileHandler¶
- class torchsig.utils.file_handlers.zarr.ZarrFileHandler(root: str, batch_size: int = 1)[source]¶
Bases:
TorchSigFileHandlerHandler for reading and writing data to/from a Zarr file format.
This class extends the TorchSigFileHandler and provides functionality to handle reading, writing, and managing Zarr-based storage for dataset samples.
Methods
Checks if the Zarr file exists at the specified path.
loadsetupReturn size of dataset
Loads a sample from the Zarr file at the specified index (without instantiating a ZarrFileHandler)
teardownWrites a sample (data and targets) to the Zarr file at the specified index.
Attributes
- exists() bool[source]¶
Checks if the Zarr file exists at the specified path.
- Returns:
True if the Zarr file exists, otherwise False.
- Return type:
- write(batch_idx: int, batch: Any) None[source]¶
Writes a sample (data and targets) to the Zarr file at the specified index.
- Parameters:
idx (int) – The index at which to store the data in the Zarr file.
data (np.ndarray) – The data to write to the Zarr file.
targets (Any) – The corresponding targets to write as metadata for the sample.
Notes
If the index is greater than the current size of the array, the array is expanded to accommodate the new sample.
- static static_load(filename: str, idx: int) Tuple[ndarray, List[Dict[str, Any]]][source]¶
Loads a sample from the Zarr file at the specified index (without instantiating a ZarrFileHandler)
- Parameters:
- Returns:
The data and the associated metadata for the sample.
- Return type:
Tuple[np.ndarray, List[Dict[str, Any]]]
- Raises:
IndexError – If the index is out of bounds.