Commit 51663847 authored by Jait Dixit's avatar Jait Dixit

Replace pickle usage with dtype.name for datatypes in all classes

parent 40ec4ef7
......@@ -897,7 +897,7 @@ class Field(Loggable, Versionable, object):
hdf5_group['field_type_axes'] = pickle.dumps(self.field_type_axes)
hdf5_group['domain_axes'] = pickle.dumps(self.domain_axes)
hdf5_group['dtype'] = pickle.dumps(self.dtype)
hdf5_group['dtype'] = self.dtype.name
hdf5_group['distribution_strategy'] = self.distribution_strategy
hdf5_group['num_domain'] = len(self.domain)
hdf5_group['num_ft'] = len(self.field_type)
......@@ -935,7 +935,7 @@ class Field(Loggable, Versionable, object):
new_field.domain_axes = pickle.loads(hdf5_group['domain_axes'][()])
new_field.field_type_axes = pickle.loads(hdf5_group['field_type_axes'][()])
new_field._val = loopback_get('val')
new_field.dtype = pickle.loads(hdf5_group['dtype'][()])
new_field.dtype = np.dtype(hdf5_group['dtype'][()])
new_field.distribution_strategy = hdf5_group['distribution_strategy'][()]
return new_field
......
......@@ -217,7 +217,7 @@ class GLSpace(Versionable, Space):
def _to_hdf5(self, hdf5_group):
hdf5_group['nlat'] = self.nlat
hdf5_group['nlon'] = self.nlon
hdf5_group['dtype'] = pickle.dumps(self.dtype)
hdf5_group['dtype'] = self.dtype.name
return None
......@@ -226,7 +226,7 @@ class GLSpace(Versionable, Space):
result = cls(
nlat=hdf5_group['nlat'][()],
nlon=hdf5_group['nlon'][()],
dtype=pickle.loads(hdf5_group['dtype'][()])
dtype=np.dtype(hdf5_group['dtype'][()])
)
return result
......@@ -33,8 +33,6 @@
"""
from __future__ import division
import pickle
import numpy as np
import d2o
......@@ -211,13 +209,13 @@ class HPSpace(Versionable, Space):
def _to_hdf5(self, hdf5_group):
hdf5_group['nside'] = self.nside
hdf5_group['dtype'] = pickle.dumps(self.dtype)
hdf5_group['dtype'] = self.dtype.name
return None
@classmethod
def _from_hdf5(cls, hdf5_group, loopback_get):
result = cls(
nside=hdf5_group['nside'][()],
dtype=pickle.loads(hdf5_group['dtype'][()])
dtype=np.dtype(hdf5_group['dtype'][()])
)
return result
from __future__ import division
import pickle
import numpy as np
from keepers import Versionable
......@@ -188,13 +187,13 @@ class LMSpace(Versionable, Space):
def _to_hdf5(self, hdf5_group):
hdf5_group['lmax'] = self.lmax
hdf5_group['dtype'] = pickle.dumps(self.dtype)
hdf5_group['dtype'] = self.dtype.name
return None
@classmethod
def _from_hdf5(cls, hdf5_group, loopback_get):
result = cls(
lmax=hdf5_group['lmax'][()],
dtype=pickle.loads(hdf5_group['dtype'][()])
dtype=np.dtype(hdf5_group['dtype'][()])
)
return result
......@@ -167,7 +167,7 @@ class PowerSpace(Versionable, Space):
hdf5_group['kindex'] = self.kindex
hdf5_group['rho'] = self.rho
hdf5_group['pundex'] = self.pundex
hdf5_group['dtype'] = pickle.dumps(self.dtype)
hdf5_group['dtype'] = self.dtype.name
return {
'harmonic_domain': self.harmonic_domain,
......@@ -182,7 +182,7 @@ class PowerSpace(Versionable, Space):
# reset class
new_ps.__class__ = cls
# set all values
new_ps.dtype = pickle.loads(hdf5_group['dtype'][()])
new_ps.dtype = np.dtype(hdf5_group['dtype'][()])
new_ps._harmonic_domain = loopback_get('harmonic_domain')
new_ps._log = hdf5_group['log'][()]
new_ps._nbin = pickle.loads(hdf5_group['nbin'][()])
......
......@@ -33,8 +33,6 @@
"""
from __future__ import division
import pickle
import numpy as np
from keepers import Versionable
......@@ -331,7 +329,7 @@ class RGSpace(Versionable, Space):
hdf5_group['zerocenter'] = self.zerocenter
hdf5_group['distances'] = self.distances
hdf5_group['harmonic'] = self.harmonic
hdf5_group['dtype'] = pickle.dumps(self.dtype)
hdf5_group['dtype'] = self.dtype.name
return None
......@@ -342,6 +340,6 @@ class RGSpace(Versionable, Space):
zerocenter=hdf5_group['zerocenter'][:],
distances=hdf5_group['distances'][:],
harmonic=hdf5_group['harmonic'][()],
dtype=pickle.loads(hdf5_group['dtype'][()])
dtype=np.dtype(hdf5_group['dtype'][()])
)
return result
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