mlmc.sample_storage_hdf.SampleStorageHDF

class mlmc.sample_storage_hdf.SampleStorageHDF(file_path)[source]

Store and manage sample data in an HDF5 file.

This implementation of the SampleStorage interface provides efficient persistent storage for MLMC simulation results using HDF5.

__init__(file_path)[source]

Initialize the HDF5 storage and create or load the file structure.

Parameters:

file_path – Absolute path to the HDF5 file. If the file exists, it will be loaded instead of created.

Methods

__init__(file_path)

Initialize the HDF5 storage and create or load the file structure.

chunks([level_id, n_samples])

Create a generator yielding chunk specifications for collected data.

clear_failed()

Clear all failed sample records from storage.

failed_samples()

Return dictionary of failed samples for each level.

get_level_ids()

Get identifiers of all levels stored in HDF5.

get_level_parameters()

Load stored level parameters (e.g., step sizes or resolutions).

get_n_collected()

Get the number of collected (stored) samples for each level.

get_n_levels()

Get total number of levels present in storage.

get_n_ops()

Get the average number of operations per sample for each level.

load_result_format()

Load and reconstruct the result format from HDF5.

load_scheduled_samples()

Load scheduled samples from storage.

n_finished()

Count the number of finished samples for each level.

sample_pairs()

Retrieve all sample pairs from storage.

sample_pairs_level(chunk_spec)

Retrieve samples for a specific level and chunk.

save_global_data(level_parameters, result_format)

Save HDF5 global attributes including simulation parameters and result format.

save_n_ops(n_ops)

Save the estimated number of operations (e.g., runtime) for each level.

save_result_format(result_format, res_dtype)

Save result format metadata to HDF5.

save_samples(successful, failed)

Save successful and failed samples to the HDF5 storage.

save_scheduled_samples(level_id, samples)

Append scheduled sample identifiers for a specific level.

unfinished_ids()

Return identifiers of all unfinished samples.