Commit 71d68281 authored by theos's avatar theos
Browse files

Fixed import structure.

parent 3193a3ac
......@@ -49,7 +49,7 @@ from nifty.field import Field
from nifty.config import about,\
nifty_configuration as gc,\
dependency_injector as gdi
from nifty.nifty_paradict import rg_space_paradict
from rg_space_paradict import RGSpaceParadict
import nifty.nifty_utilities as utilities
MPI = gdi[gc['mpi_module']]
......@@ -150,10 +150,10 @@ class RGSpace(Space):
None
"""
self.paradict = rg_space_paradict(shape=shape,
zerocenter=zerocenter,
distances=distances,
harmonic=harmonic)
self.paradict = RGSpaceParadict(shape=shape,
zerocenter=zerocenter,
distances=distances,
harmonic=harmonic)
self.dtype = np.dtype(dtype)
@property
......
# -*- coding: utf-8 -*-
import numpy as np
from nifty.config import about
from nifty.spaces.space import SpaceParadict
class RGSpaceParadict(SpaceParadict):
def __init__(self, shape, zerocenter, distances, harmonic):
if not hasattr(self, 'parameters'):
self.parameters = {}
self.parameters.__setitem__('shape', shape)
self.parameters.__setitem__('harmonic', harmonic)
SpaceParadict.__init__(
self, zerocenter=zerocenter, distances=distances)
def __setitem__(self, key, arg):
if key not in ['shape', 'zerocenter', 'distances']:
raise ValueError(about._errors.cstring(
"ERROR: Unsupported RGSpace parameter:" + key))
if key == 'shape':
temp = np.empty(len(self['shape']), dtype=np.int)
temp[:] = arg
temp = tuple(temp)
elif key == 'zerocenter':
temp = np.empty(len(self['shape']), dtype=bool)
temp[:] = arg
temp = tuple(temp)
elif key == 'distances':
if arg is None:
if self['harmonic']:
temp = np.ones_like(self['shape'], dtype=np.float)
else:
temp = 1 / np.array(self['shape'], dtype=np.float)
else:
temp = np.empty(len(self['shape']), dtype=np.float)
temp[:] = arg
temp = tuple(temp)
elif key == 'harmonic':
temp = bool(arg)
self.parameters.__setitem__(key, temp)
# -*- coding: utf-8 -*-
from space import Space
from space_paradict import SpaceParadict
\ No newline at end of file
......@@ -145,7 +145,7 @@ import numpy as np
import pylab as pl
from nifty.config import about
from nifty_paradict import space_paradict
from space_paradict import SpaceParadict
class Space(object):
......@@ -198,7 +198,7 @@ class Space(object):
-------
None.
"""
self.paradict = space_paradict(**kwargs)
self.paradict = SpaceParadict(**kwargs)
# parse dtype
dtype = np.dtype(dtype)
......
# -*- coding: utf-8 -*-
class SpaceParadict(object):
def __init__(self, **kwargs):
if not hasattr(self, 'parameters'):
self.parameters = {}
for key in kwargs:
self[key] = kwargs[key]
def __iter__(self):
return self.parameters.__iter__()
def __eq__(self, other):
return (isinstance(other, self.__class__) and
self.__dict__ == other.__dict__)
def __ne__(self, other):
return not self.__eq__(other)
def __repr__(self):
return self.parameters.__repr__()
def __setitem__(self, key, arg):
raise NotImplementedError
def __getitem__(self, key):
return self.parameters.__getitem__(key)
def __hash__(self):
result_hash = 0
for (key, item) in self.parameters.items():
try:
temp_hash = hash(item)
except TypeError:
temp_hash = hash(tuple(item))
result_hash ^= temp_hash ^ int(hash(key)/131)
return result_hash
......@@ -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__ = '2.0.0a1'
\ No newline at end of file
__version__ = '3.0.0a1'
\ No newline at end of file
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