Skip to content

Commit

Permalink
small patch to html repr
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Nov 6, 2024
1 parent be602e5 commit abc0efe
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/hdmf/backends/hdf5/h5tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,23 +1609,26 @@ def set_dataio(cls, **kwargs):
def generate_dataset_html(dataset):
"""Generates an html representation for a dataset for the HDF5IO class"""

# get info from hdf5 dataset
compressed_size = dataset.id.get_storage_size()
if hasattr(dataset, "nbytes"): # TODO: Remove this after h5py minimal version is larger than 3.0
uncompressed_size = dataset.nbytes
else:
uncompressed_size = dataset.size * dataset.dtype.itemsize
compression_ratio = uncompressed_size / compressed_size if compressed_size != 0 else "undefined"

hdf5_info_dict = {"Chunk shape": dataset.chunks,
"Compression": dataset.compression,
"Compression opts": dataset.compression_opts,
"Compression ratio": compression_ratio}

# get basic array info
array_info_dict = get_basic_array_info(dataset)
array_info_dict.update(hdf5_info_dict)

if isinstance(dataset, h5py.Dataset):

# get info from hdf5 dataset
compressed_size = dataset.id.get_storage_size()
if hasattr(dataset, "nbytes"): # TODO: Remove this after h5py minimal version is larger than 3.0
uncompressed_size = dataset.nbytes
else:
uncompressed_size = dataset.size * dataset.dtype.itemsize
compression_ratio = uncompressed_size / compressed_size if compressed_size != 0 else "undefined"

hdf5_info_dict = {
"Chunk shape": dataset.chunks,
"Compression": dataset.compression,
"Compression opts": dataset.compression_opts,
"Compression ratio": compression_ratio,
}

array_info_dict.update(hdf5_info_dict)

# generate html repr
repr_html = generate_array_html_repr(array_info_dict, dataset, "HDF5 dataset")

Expand Down

0 comments on commit abc0efe

Please sign in to comment.