Commit be57ac4e authored by theos's avatar theos
Browse files

Added default_datamodel to nifty_config.py.

Added first version of field_type classes.
parent 89729ee5
......@@ -49,6 +49,9 @@ from nifty_utilities import *
from nifty_paradict import space_paradict,\
point_space_paradict,\
nested_space_paradict
from field_types import Field_array
from operators import *
## optional submodule `rg`
......
......@@ -50,6 +50,12 @@ variable_verbosity = keepers.Variable('verbosity',
lambda z: z == abs(int(z)),
genus='int')
variable_default_datamodel = keepers.Variable(
'default_datamodel',
['fftw', 'equal'],
lambda z: (('pyfftw' in dependency_injector)
if z == 'fftw' else True),
genus='str')
nifty_configuration = keepers.get_Configuration(
'NIFTy',
......@@ -58,6 +64,7 @@ nifty_configuration = keepers.get_Configuration(
variable_use_healpy,
variable_use_libsharp,
variable_verbosity,
variable_default_datamodel,
],
path=os.path.expanduser('~') + "/.nifty/nifty_config")
########
......@@ -80,6 +87,7 @@ variable_default_comm = keepers.Variable(
nifty_configuration.register(variable_default_comm)
########
########
......
# -*- coding: utf-8 -*-
from field_array import Field_array
\ No newline at end of file
# -*- coding: utf-8 -*-
class Base_field_type(object):
def __init__(self, shape):
self.shape = shape
@property
def shape(self):
return self._shape
@shape.setter
def shape(self, shape):
try:
new_shape = tuple([int(i) for i in shape])
except TypeError:
new_shape = (int(shape), )
self._shape = new_shape
def process(self, method_name, array, inplace=True, **kwargs):
try:
result_array = self.__getattr__(method_name)(array,
inplace,
**kwargs)
except AttributeError:
if inplace:
result_array = array
else:
result_array = array.copy()
return result_array
# -*- coding: utf-8 -*-
from base_field_type import Base_field_type
class Field_array(Base_field_type):
pass
......@@ -103,8 +103,9 @@ class field(object):
"""
def __init__(self, domain=None, val=None, codomain=None,
comm=gc['default_comm'], copy=False, dtype=None,
datamodel='fftw', **kwargs):
dtype=None, field_type=None, copy=False,
datamodel=gc['default_datamodel'], comm=gc['default_comm'],
**kwargs):
"""
Sets the attributes for a field class instance.
......@@ -232,9 +233,9 @@ class field(object):
domain = self.domain
i = 0
axis_list = []
for space in domain:
for sp in domain:
l = []
for j in range(len(space.get_shape())):
for j in range(len(sp.get_shape())):
l += [i]
i += 1
axis_list += [tuple(l)]
......
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