Commit c5fb7675 authored by robert.vincze's avatar robert.vincze

TVB 2599: None fields are not stored in H5 files now and their default value...

TVB 2599: None fields are not stored in H5 files now and their default value will be used after deserialization.
parent e0607be1
......@@ -35,6 +35,7 @@ import numpy
import scipy.sparse
import typing
from tvb.basic.neotraits.api import HasTraits, Attr, NArray
from tvb.core.entities.file.exceptions import MissingDataSetException
from tvb.datatypes import equations
......@@ -85,13 +86,18 @@ class Scalar(Accessor):
# type: (typing.Union[str, int, float]) -> None
# noinspection PyProtectedMember
val = self.trait_attribute._validate_set(None, val)
self.owner.storage_manager.set_metadata({self.field_name: val})
if val is not None:
self.owner.storage_manager.set_metadata({self.field_name: val})
def load(self):
# type: () -> typing.Union[str, int, float]
# assuming here that the h5 will return the type we stored.
# if paranoid do self.trait_attribute.field_type(value)
return self.owner.storage_manager.get_metadata()[self.field_name]
metadata = self.owner.storage_manager.get_metadata()
if self.field_name in metadata:
return metadata[self.field_name]
raise MissingDataSetException(self.field_name)
class Uuid(Scalar):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment