Modified node values as the number of children of each group. When nodes are datasets, their value is 1.

This commit is contained in:
2024-04-02 18:48:50 +02:00
parent 9071120e50
commit 9cde013be0

View File

@ -158,10 +158,11 @@ def get_parent_child_relationships(file: h5py.File):
parent = ['']
#values = [file.attrs['count']]
# TODO: maybe we should make this more general and not dependent on file_list attribute?
if 'file_list' in file.attrs.keys():
values = [len(file.attrs['file_list'])]
else:
values = [1]
#if 'file_list' in file.attrs.keys():
# values = [len(file.attrs['file_list'])]
#else:
# values = [1]
values = [len(file.keys())]
def node_visitor(name,obj):
#if isinstance(obj,h5py.Group):
@ -169,10 +170,12 @@ def get_parent_child_relationships(file: h5py.File):
parent.append(obj.parent.name)
#nodes.append(os.path.split(obj.name)[1])
#parent.append(os.path.split(obj.parent.name)[1])
if isinstance(obj,h5py.Dataset) or not 'file_list' in obj.attrs.keys():
if isinstance(obj,h5py.Dataset):# or not 'file_list' in obj.attrs.keys():
values.append(1)
else:
values.append(len(obj.attrs['file_list']))
values.append(len(obj.keys()))
#values.append(len(obj.attrs['file_list']))
file.visititems(node_visitor)
return nodes, parent, values