diff --git a/nifty/domain_object.py b/nifty/domain_object.py index 3142fa641f5e14e4fb87b0c90ff49769dde4c822..0dabcb32e1e41344939bdd21eaf9790d2082f099 100644 --- a/nifty/domain_object.py +++ b/nifty/domain_object.py @@ -20,13 +20,12 @@ from __future__ import division import abc from .nifty_meta import NiftyMeta -from keepers import Loggable,\ - Versionable +from keepers import Loggable from future.utils import with_metaclass class DomainObject(with_metaclass( - NiftyMeta, type('NewBase', (Versionable, Loggable, object), {}))): + NiftyMeta, type('NewBase', (Loggable, object), {}))): """The abstract class that can be used as a domain for a field. This holds all the information and functionality a field needs to know @@ -224,13 +223,3 @@ class DomainObject(with_metaclass( """ return x - - # ---Serialization--- - - def _to_hdf5(self, hdf5_group): - return None - - @classmethod - def _from_hdf5(cls, hdf5_group, repository): - result = cls() - return result diff --git a/nifty/field.py b/nifty/field.py index c8e12f83c0ec39348579118b9f41f6756267b627..a589340fbea74ae2fb322e1d387e6cd2df56891f 100644 --- a/nifty/field.py +++ b/nifty/field.py @@ -23,8 +23,7 @@ from builtins import range import ast import numpy as np -from keepers import Versionable,\ - Loggable +from keepers import Loggable from .domain_object import DomainObject @@ -35,7 +34,7 @@ from .random import Random from functools import reduce -class Field(Loggable, Versionable, object): +class Field(Loggable, object): """ The discrete representation of a continuous field over multiple spaces. In NIFTY, Fields are used to store data arrays and carry all the needed @@ -1444,47 +1443,6 @@ class Field(Loggable, Versionable, object): "\n - min.,max. = " + str(minmax) + \ "\n - mean = " + str(mean) - # ---Serialization--- - - def _to_hdf5(self, hdf5_group): - hdf5_group.attrs['dtype'] = self.dtype.name - hdf5_group.attrs['domain_axes'] = str(self.domain_axes) - hdf5_group['num_domain'] = len(self.domain) - - 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] - - return ret_dict - - @classmethod - def _from_hdf5(cls, hdf5_group, repository): - # create empty field - new_field = EmptyField() - # reset class - new_field.__class__ = cls - # set values - temp_domain = [] - for i in range(hdf5_group['num_domain'][()]): - temp_domain.append(repository.get('s_' + str(i), hdf5_group)) - new_field.domain = tuple(temp_domain) - - new_field.domain_axes = ast.literal_eval( - hdf5_group.attrs['domain_axes']) - - try: - new_field._val = repository.get('val', hdf5_group) - except(KeyError): - new_field._val = None - - new_field.dtype = np.dtype(hdf5_group.attrs['dtype']) - - return new_field - class EmptyField(Field): def __init__(self): diff --git a/nifty/field_types/field_array.py b/nifty/field_types/field_array.py index 8c660b1b6e984410ccca5f81be8cb47870e4bade..6e7d6047d166b9aee92df287ba85e1c60e9281f7 100644 --- a/nifty/field_types/field_array.py +++ b/nifty/field_types/field_array.py @@ -39,14 +39,3 @@ class FieldArray(FieldType): @property def dim(self): return reduce(lambda x, y: x*y, self.shape) - - # ---Serialization--- - - def _to_hdf5(self, hdf5_group): - hdf5_group['shape'] = self.shape - return None - - @classmethod - def _from_hdf5(cls, hdf5_group, loopback_get): - result = cls(shape=hdf5_group['shape'][:]) - return result diff --git a/nifty/operators/linear_operator/linear_operator.py b/nifty/operators/linear_operator/linear_operator.py index d1833976feae48b10133ea0193d4e04af17fb5d7..345e24984a829a75e7f096db5ae0a9894f2fe9a4 100644 --- a/nifty/operators/linear_operator/linear_operator.py +++ b/nifty/operators/linear_operator/linear_operator.py @@ -20,15 +20,14 @@ from builtins import str import abc from ...nifty_meta import NiftyMeta -from keepers import Loggable,\ - Versionable +from keepers import Loggable from ...field import Field from ... import nifty_utilities as utilities from future.utils import with_metaclass class LinearOperator(with_metaclass( - NiftyMeta, type('NewBase', (Versionable, Loggable, object), {}))): + NiftyMeta, type('NewBase', (Loggable, object), {}))): """NIFTY base class for linear operators. The base NIFTY operator class is an abstract class from which diff --git a/nifty/spaces/gl_space/gl_space.py b/nifty/spaces/gl_space/gl_space.py index 220e10a744037a77235fc02e0dc00e803e3a5d05..3c1d2a45b05b8693236108309c415720a5a17032 100644 --- a/nifty/spaces/gl_space/gl_space.py +++ b/nifty/spaces/gl_space/gl_space.py @@ -180,20 +180,3 @@ class GLSpace(Space): if nlon < 1: raise ValueError("nlon must be a positive number.") return nlon - - # ---Serialization--- - - def _to_hdf5(self, hdf5_group): - hdf5_group['nlat'] = self.nlat - hdf5_group['nlon'] = self.nlon - - return None - - @classmethod - def _from_hdf5(cls, hdf5_group, repository): - result = cls( - nlat=hdf5_group['nlat'][()], - nlon=hdf5_group['nlon'][()], - ) - - return result diff --git a/nifty/spaces/hp_space/hp_space.py b/nifty/spaces/hp_space/hp_space.py index 8a8ccdbb88c1a2667d9d73deb61d530c4f0faaf4..c328f40d261a8469a48476d2fa7a0681372a8da7 100644 --- a/nifty/spaces/hp_space/hp_space.py +++ b/nifty/spaces/hp_space/hp_space.py @@ -139,16 +139,3 @@ class HPSpace(Space): if nside < 1: raise ValueError("nside must be >=1.") return nside - - # ---Serialization--- - - def _to_hdf5(self, hdf5_group): - hdf5_group['nside'] = self.nside - return None - - @classmethod - def _from_hdf5(cls, hdf5_group, repository): - result = cls( - nside=hdf5_group['nside'][()], - ) - return result diff --git a/nifty/spaces/lm_space/lm_space.py b/nifty/spaces/lm_space/lm_space.py index 6c8010fdebb629f6b7aac25bc72200d8d19cf207..fe9257b34446e751100f7ee3413f1dd5dfe6e3e8 100644 --- a/nifty/spaces/lm_space/lm_space.py +++ b/nifty/spaces/lm_space/lm_space.py @@ -187,16 +187,3 @@ class LMSpace(Space): if lmax < 0: raise ValueError("lmax must be >=0.") return lmax - - # ---Serialization--- - - def _to_hdf5(self, hdf5_group): - hdf5_group['lmax'] = self.lmax - return None - - @classmethod - def _from_hdf5(cls, hdf5_group, repository): - result = cls( - lmax=hdf5_group['lmax'][()], - ) - return result diff --git a/nifty/spaces/power_space/power_space.py b/nifty/spaces/power_space/power_space.py index e8e0ea360159aaba4a874dc689ca294fe0508aa1..0c9585a4a76383277ab4f62bb95cd3405f4eddbf 100644 --- a/nifty/spaces/power_space/power_space.py +++ b/nifty/spaces/power_space/power_space.py @@ -277,18 +277,3 @@ class PowerSpace(Space): """Degeneracy factor of the individual k-vectors. """ return self._rho - - # ---Serialization--- - - def _to_hdf5(self, hdf5_group): - hdf5_group.attrs['binbounds'] = str(self._binbounds) - - return { - 'harmonic_partner': self.harmonic_partner, - } - - @classmethod - def _from_hdf5(cls, hdf5_group, repository): - hp = repository.get('harmonic_partner', hdf5_group) - bb = ast.literal_eval(hdf5_group.attrs['binbounds']) - return PowerSpace(hp, binbounds=bb) diff --git a/nifty/spaces/rg_space/rg_space.py b/nifty/spaces/rg_space/rg_space.py index 870b3c46d166e792ca18c301088592cc41c55a07..adb3a6c200506dbd2992bb63057b5f4cae992153 100644 --- a/nifty/spaces/rg_space/rg_space.py +++ b/nifty/spaces/rg_space/rg_space.py @@ -252,21 +252,3 @@ class RGSpace(Space): temp = np.empty(len(self.shape), dtype=np.float64) temp[:] = distances return tuple(temp) - - # ---Serialization--- - - def _to_hdf5(self, hdf5_group): - hdf5_group['shape'] = self.shape - hdf5_group['distances'] = self.distances - hdf5_group['harmonic'] = self.harmonic - - return None - - @classmethod - def _from_hdf5(cls, hdf5_group, repository): - result = cls( - shape=hdf5_group['shape'][:], - distances=hdf5_group['distances'][:], - harmonic=hdf5_group['harmonic'][()], - ) - return result