Commit 85fcff13 authored by Theo Steininger's avatar Theo Steininger

Fixed bugs serialization.

Increased version number to 3.0.4
parent f389aa57
Pipeline #10585 failed with stages
in 37 minutes and 18 seconds
......@@ -836,7 +836,10 @@ class Field(Loggable, Versionable, object):
hdf5_group.attrs['domain_axes'] = str(self.domain_axes)
hdf5_group['num_domain'] = len(self.domain)
ret_dict = {'val': self.val}
if self._val is None:
ret_dict = {}
else:
ret_dict = {'val': self.val}
for i in range(len(self.domain)):
ret_dict['s_' + str(i)] = self.domain[i]
......@@ -856,7 +859,12 @@ class Field(Loggable, Versionable, object):
new_field.domain = tuple(temp_domain)
exec('new_field.domain_axes = ' + hdf5_group.attrs['domain_axes'])
new_field._val = repository.get('val', hdf5_group)
try:
new_field._val = repository.get('val', hdf5_group)
except(KeyError):
new_field._val = None
new_field.dtype = np.dtype(hdf5_group.attrs['dtype'])
new_field.distribution_strategy =\
hdf5_group.attrs['distribution_strategy']
......
# -*- coding: utf-8 -*-
import pickle
import numpy as np
from field_type import FieldType
......@@ -29,14 +27,14 @@ class FieldArray(FieldType):
def _to_hdf5(self, hdf5_group):
hdf5_group['shape'] = self.shape
hdf5_group['dtype'] = pickle.dumps(self.dtype)
hdf5_group.attrs['dtype'] = self.dtype.name
return None
@classmethod
def _from_hdf5(cls, hdf5_group, loopback_get):
result = cls(
hdf5_group['shape'][:],
pickle.loads(hdf5_group['dtype'][()])
shape=hdf5_group['shape'][:],
dtype=np.dtype(hdf5_group.attrs['dtype'])
)
return result
......@@ -4,4 +4,4 @@
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module module
__version__ = '3.0.3'
__version__ = '3.0.4'
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