Skip to content
Snippets Groups Projects
Commit 043d13c4 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

SW-43: fix avoid modification of the source dict while storing. Fixing...

SW-43: fix avoid modification of the source dict while storing. Fixing iteration over the attribute and the values of the h5 dataset.
parent 0659ea41
No related branches found
No related tags found
1 merge request!44Merge back holography to master
......@@ -136,13 +136,16 @@ class HolographyDataset():
elif attribute_value != other_value:
this_equality = False
except Exception as e:
logger.warn("Cannot compare HDS values!", attribute_name, type(attribute_value), e)
logger.warn("Cannot compare HDS values!", attribute_name, type(attribute_value),
e)
return False
try:
equality = equality and this_equality
except Exception as e:
logger.warn("Comparison of two values resulted in something that is neither True nor False!", attribute_name, type(attribute_value), type(other_value))
logger.warn(
"Comparison of two values resulted in something that is neither True nor False!",
attribute_name, type(attribute_value), type(other_value))
return False
return equality
......@@ -346,7 +349,8 @@ class HolographyDataset():
logger.info("RA DEC = %s", hds.ra_dec)
logger.info("Data = %s", hds.data)
else:
logger.warn("The object passed is not a HolographyDataset instance. Cannot print any data.")
logger.warn(
"The object passed is not a HolographyDataset instance. Cannot print any data.")
@staticmethod
def _read_grouped_data(h5file, uri):
......@@ -363,7 +367,7 @@ class HolographyDataset():
result = dict()
# Read the attributes in the hdf5 dataset
for attribute_key, attribute_value in starting_leaf.attrs:
for attribute_key, attribute_value in starting_leaf.attrs.items():
if 'ATTRIBUTES' not in result:
result['ATTRIBUTES'] = dict()
result['ATTRIBUTES'][attribute_key] = attribute_value
......@@ -399,12 +403,14 @@ class HolographyDataset():
starting_leaf = h5file[uri]
# Store the attributes in the hdf5 dataset
attributes = data_to_store.pop('ATTRIBUTES', dict())
attributes = data_to_store.get('ATTRIBUTES', dict())
for attribute_key, attribute_value in attributes.items():
starting_leaf.attrs[attribute_key] = attribute_value
for key, value in data_to_store.items():
if key is 'ATTRIBUTES':
continue
if isinstance(value, dict) is True:
HolographyDataset._store_grouped_data(h5file, '/'.join([uri, key]), value)
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment