Commit bc3f10ca authored by csongor's avatar csongor
Browse files

WIP: remove datamodel from spaces.

parent 5cbe6880
...@@ -121,7 +121,7 @@ class lm_space(point_space): ...@@ -121,7 +121,7 @@ class lm_space(point_space):
""" """
def __init__(self, lmax, mmax=None, dtype=np.dtype('complex128'), def __init__(self, lmax, mmax=None, dtype=np.dtype('complex128'),
datamodel='not', comm=gc['default_comm']): comm=gc['default_comm']):
""" """
Sets the attributes for an lm_space class instance. Sets the attributes for an lm_space class instance.
...@@ -166,16 +166,6 @@ class lm_space(point_space): ...@@ -166,16 +166,6 @@ class lm_space(point_space):
dtype = np.dtype('complex128') dtype = np.dtype('complex128')
self.dtype = dtype self.dtype = dtype
# set datamodel
if datamodel not in ['not']:
about.warnings.cprint(
"WARNING: %s is not a recommended datamodel for lm_space."
% datamodel)
if datamodel not in LM_DISTRIBUTION_STRATEGIES:
raise ValueError(about._errors.cstring(
"ERROR: %s is not a valid datamodel" % datamodel))
self.datamodel = datamodel
self.discrete = True self.discrete = True
self.harmonic = True self.harmonic = True
self.distances = (np.float(1),) self.distances = (np.float(1),)
...@@ -185,7 +175,6 @@ class lm_space(point_space): ...@@ -185,7 +175,6 @@ class lm_space(point_space):
lmax=self.paradict['lmax'], lmax=self.paradict['lmax'],
dim=self.get_dim(), dim=self.get_dim(),
comm=self.comm, comm=self.comm,
datamodel=self.datamodel,
allowed_distribution_strategies=LM_DISTRIBUTION_STRATEGIES) allowed_distribution_strategies=LM_DISTRIBUTION_STRATEGIES)
@property @property
...@@ -337,9 +326,6 @@ class lm_space(point_space): ...@@ -337,9 +326,6 @@ class lm_space(point_space):
if self.comm is not codomain.comm: if self.comm is not codomain.comm:
return False return False
if self.datamodel is not codomain.datamodel:
return False
elif isinstance(codomain, gl_space): elif isinstance(codomain, gl_space):
# lmax==mmax # lmax==mmax
# nlat==lmax+1 # nlat==lmax+1
...@@ -400,13 +386,11 @@ class lm_space(point_space): ...@@ -400,13 +386,11 @@ class lm_space(point_space):
nlat = self.paradict['lmax'] + 1 nlat = self.paradict['lmax'] + 1
nlon = self.paradict['lmax'] * 2 + 1 nlon = self.paradict['lmax'] * 2 + 1
return gl_space(nlat=nlat, nlon=nlon, dtype=new_dtype, return gl_space(nlat=nlat, nlon=nlon, dtype=new_dtype,
datamodel=self.datamodel,
comm=self.comm) comm=self.comm)
elif coname == 'hp' or (coname is None and not gc['lm2gl']): elif coname == 'hp' or (coname is None and not gc['lm2gl']):
nside = (self.paradict['lmax']+1) // 3 nside = (self.paradict['lmax']+1) // 3
return hp_space(nside=nside, return hp_space(nside=nside,
datamodel=self.datamodel,
comm=self.comm) comm=self.comm)
else: else:
...@@ -557,10 +541,10 @@ class lm_space(point_space): ...@@ -557,10 +541,10 @@ class lm_space(point_space):
raise ValueError(about._errors.cstring( raise ValueError(about._errors.cstring(
"ERROR: unsupported codomain.")) "ERROR: unsupported codomain."))
if self.datamodel != 'not': # if self.datamodel != 'not':
about.warnings.cprint( # about.warnings.cprint(
"WARNING: Field data is consolidated to all nodes for " # "WARNING: Field data is consolidated to all nodes for "
"external alm2map method!") # "external alm2map method!")
np_x = x.get_full_data() np_x = x.get_full_data()
...@@ -630,10 +614,10 @@ class lm_space(point_space): ...@@ -630,10 +614,10 @@ class lm_space(point_space):
elif sigma < 0: elif sigma < 0:
raise ValueError(about._errors.cstring("ERROR: invalid sigma.")) raise ValueError(about._errors.cstring("ERROR: invalid sigma."))
if self.datamodel != 'not': # if self.datamodel != 'not':
about.warnings.cprint( # about.warnings.cprint(
"WARNING: Field data is consolidated to all nodes for " # "WARNING: Field data is consolidated to all nodes for "
"external smoothalm method!") # "external smoothalm method!")
np_x = x.get_full_data() np_x = x.get_full_data()
...@@ -673,10 +657,10 @@ class lm_space(point_space): ...@@ -673,10 +657,10 @@ class lm_space(point_space):
lmax = self.paradict['lmax'] lmax = self.paradict['lmax']
mmax = self.paradict['mmax'] mmax = self.paradict['mmax']
if self.datamodel != 'not': # if self.datamodel != 'not':
about.warnings.cprint( # about.warnings.cprint(
"WARNING: Field data is consolidated to all nodes for " # "WARNING: Field data is consolidated to all nodes for "
"external anaalm/alm2cl method!") # "external anaalm/alm2cl method!")
np_x = x.get_full_data() np_x = x.get_full_data()
...@@ -964,7 +948,7 @@ class gl_space(point_space): ...@@ -964,7 +948,7 @@ class gl_space(point_space):
""" """
def __init__(self, nlat, nlon=None, dtype=np.dtype('float64'), def __init__(self, nlat, nlon=None, dtype=np.dtype('float64'),
datamodel='not', comm=gc['default_comm']): comm=gc['default_comm']):
""" """
Sets the attributes for a gl_space class instance. Sets the attributes for a gl_space class instance.
...@@ -1004,16 +988,6 @@ class gl_space(point_space): ...@@ -1004,16 +988,6 @@ class gl_space(point_space):
dtype = np.dtype('float') dtype = np.dtype('float')
self.dtype = dtype self.dtype = dtype
# set datamodel
if datamodel not in ['not']:
about.warnings.cprint(
"WARNING: %s is not a recommended datamodel for gl_space."
% datamodel)
if datamodel not in GL_DISTRIBUTION_STRATEGIES:
raise ValueError(about._errors.cstring(
"ERROR: %s is not a valid datamodel" % datamodel))
self.datamodel = datamodel
self.discrete = False self.discrete = False
self.harmonic = False self.harmonic = False
self.distances = tuple(gl.vol(self.paradict['nlat'], self.distances = tuple(gl.vol(self.paradict['nlat'],
...@@ -1125,9 +1099,6 @@ class gl_space(point_space): ...@@ -1125,9 +1099,6 @@ class gl_space(point_space):
if not isinstance(codomain, space): if not isinstance(codomain, space):
raise TypeError(about._errors.cstring("ERROR: invalid input.")) raise TypeError(about._errors.cstring("ERROR: invalid input."))
if self.datamodel is not codomain.datamodel:
return False
if self.comm is not codomain.comm: if self.comm is not codomain.comm:
return False return False
...@@ -1160,11 +1131,9 @@ class gl_space(point_space): ...@@ -1160,11 +1131,9 @@ class gl_space(point_space):
# lmax,mmax = nlat-1,nlat-1 # lmax,mmax = nlat-1,nlat-1
if self.dtype == np.dtype('float32'): if self.dtype == np.dtype('float32'):
return lm_space(lmax=lmax, mmax=mmax, dtype=np.complex64, return lm_space(lmax=lmax, mmax=mmax, dtype=np.complex64,
datamodel=self.datamodel,
comm=self.comm) comm=self.comm)
else: else:
return lm_space(lmax=lmax, mmax=mmax, dtype=np.complex128, return lm_space(lmax=lmax, mmax=mmax, dtype=np.complex128,
datamodel=self.datamodel,
comm=self.comm) comm=self.comm)
def get_random_values(self, **kwargs): def get_random_values(self, **kwargs):
...@@ -1271,10 +1240,10 @@ class gl_space(point_space): ...@@ -1271,10 +1240,10 @@ class gl_space(point_space):
""" """
x = self.cast(x) x = self.cast(x)
if self.datamodel != 'not': # if self.datamodel != 'not':
about.warnings.cprint( # about.warnings.cprint(
"WARNING: Field data is consolidated to all nodes for " # "WARNING: Field data is consolidated to all nodes for "
"external alm2map method!") # "external alm2map method!")
np_x = x.get_full_data() np_x = x.get_full_data()
# weight # weight
...@@ -1344,10 +1313,10 @@ class gl_space(point_space): ...@@ -1344,10 +1313,10 @@ class gl_space(point_space):
lmax = codomain.paradict['lmax'] lmax = codomain.paradict['lmax']
mmax = codomain.paradict['mmax'] mmax = codomain.paradict['mmax']
if self.datamodel != 'not': # if self.datamodel != 'not':
about.warnings.cprint( # about.warnings.cprint(
"WARNING: Field data is consolidated to all nodes for " # "WARNING: Field data is consolidated to all nodes for "
"external map2alm method!") # "external map2alm method!")
np_x = x.get_full_data() np_x = x.get_full_data()
...@@ -1396,10 +1365,10 @@ class gl_space(point_space): ...@@ -1396,10 +1365,10 @@ class gl_space(point_space):
# smooth # smooth
nlat = self.paradict['nlat'] nlat = self.paradict['nlat']
if self.datamodel != 'not': # if self.datamodel != 'not':
about.warnings.cprint( # about.warnings.cprint(
"WARNING: Field data is consolidated to all nodes for " # "WARNING: Field data is consolidated to all nodes for "
"external smoothmap method!") # "external smoothmap method!")
np_x = x.get_full_data() np_x = x.get_full_data()
...@@ -1434,10 +1403,10 @@ class gl_space(point_space): ...@@ -1434,10 +1403,10 @@ class gl_space(point_space):
lmax = nlat - 1 lmax = nlat - 1
mmax = nlat - 1 mmax = nlat - 1
if self.datamodel != 'not': # if self.datamodel != 'not':
about.warnings.cprint( # about.warnings.cprint(
"WARNING: Field data is consolidated to all nodes for " # "WARNING: Field data is consolidated to all nodes for "
"external anafast method!") # "external anafast method!")
np_x = x.get_full_data() np_x = x.get_full_data()
...@@ -1657,7 +1626,7 @@ class hp_space(point_space): ...@@ -1657,7 +1626,7 @@ class hp_space(point_space):
An array with one element containing the pixel size. An array with one element containing the pixel size.
""" """
def __init__(self, nside, datamodel='not', comm=gc['default_comm']): def __init__(self, nside, comm=gc['default_comm']):
""" """
Sets the attributes for a hp_space class instance. Sets the attributes for a hp_space class instance.
...@@ -1690,16 +1659,6 @@ class hp_space(point_space): ...@@ -1690,16 +1659,6 @@ class hp_space(point_space):
self.dtype = np.dtype('float64') self.dtype = np.dtype('float64')
# set datamodel
if datamodel not in ['not']:
about.warnings.cprint(
"WARNING: %s is not a recommended datamodel for hp_space."
% datamodel)
if datamodel not in HP_DISTRIBUTION_STRATEGIES:
raise ValueError(about._errors.cstring(
"ERROR: %s is not a valid datamodel" % datamodel))
self.datamodel = datamodel
self.discrete = False self.discrete = False
self.harmonic = False self.harmonic = False
self.distances = (np.float(4*np.pi / (12*self.paradict['nside']**2)),) self.distances = (np.float(4*np.pi / (12*self.paradict['nside']**2)),)
...@@ -1804,9 +1763,6 @@ class hp_space(point_space): ...@@ -1804,9 +1763,6 @@ class hp_space(point_space):
if not isinstance(codomain, space): if not isinstance(codomain, space):
raise TypeError(about._errors.cstring("ERROR: invalid input.")) raise TypeError(about._errors.cstring("ERROR: invalid input."))
if self.datamodel is not codomain.datamodel:
return False
if self.comm is not codomain.comm: if self.comm is not codomain.comm:
return False return False
...@@ -1834,7 +1790,6 @@ class hp_space(point_space): ...@@ -1834,7 +1790,6 @@ class hp_space(point_space):
lmax = 3*self.paradict['nside'] - 1 lmax = 3*self.paradict['nside'] - 1
mmax = lmax mmax = lmax
return lm_space(lmax=lmax, mmax=mmax, dtype=np.dtype('complex128'), return lm_space(lmax=lmax, mmax=mmax, dtype=np.dtype('complex128'),
datamodel=self.datamodel,
comm=self.comm) comm=self.comm)
def get_random_values(self, **kwargs): def get_random_values(self, **kwargs):
...@@ -1952,10 +1907,11 @@ class hp_space(point_space): ...@@ -1952,10 +1907,11 @@ class hp_space(point_space):
raise ValueError(about._errors.cstring( raise ValueError(about._errors.cstring(
"ERROR: unsupported codomain.")) "ERROR: unsupported codomain."))
if self.datamodel != 'not': # TODO look at these kinds of checks maybe need replacement
about.warnings.cprint( # if self.datamodel != 'not':
"WARNING: Field data is consolidated to all nodes for " # about.warnings.cprint(
"external map2alm method!") # "WARNING: Field data is consolidated to all nodes for "
# "external map2alm method!")
np_x = x.get_full_data() np_x = x.get_full_data()
...@@ -2015,10 +1971,10 @@ class hp_space(point_space): ...@@ -2015,10 +1971,10 @@ class hp_space(point_space):
raise ValueError(about._errors.cstring("ERROR: invalid sigma.")) raise ValueError(about._errors.cstring("ERROR: invalid sigma."))
# smooth # smooth
if self.datamodel != 'not': # if self.datamodel != 'not':
about.warnings.cprint( # about.warnings.cprint(
"WARNING: Field data is consolidated to all nodes for " # "WARNING: Field data is consolidated to all nodes for "
"external smoothalm method!") # "external smoothalm method!")
np_x = x.get_full_data() np_x = x.get_full_data()
...@@ -2059,10 +2015,10 @@ class hp_space(point_space): ...@@ -2059,10 +2015,10 @@ class hp_space(point_space):
lmax = 3*nside-1 lmax = 3*nside-1
mmax = lmax mmax = lmax
if self.datamodel != 'not': # if self.datamodel != 'not':
about.warnings.cprint( # about.warnings.cprint(
"WARNING: Field data is consolidated to all nodes for " # "WARNING: Field data is consolidated to all nodes for "
"external smoothalm method!") # "external smoothalm method!")
np_x = x.get_full_data() np_x = x.get_full_data()
......
...@@ -272,7 +272,7 @@ class space(object): ...@@ -272,7 +272,7 @@ class space(object):
raise NotImplementedError(about._errors.cstring( raise NotImplementedError(about._errors.cstring(
"ERROR: no generic instance method 'getitem'.")) "ERROR: no generic instance method 'getitem'."))
def setitem(self, data, key): def setitem(self, data, update, key):
raise NotImplementedError(about._errors.cstring( raise NotImplementedError(about._errors.cstring(
"ERROR: no generic instance method 'getitem'.")) "ERROR: no generic instance method 'getitem'."))
...@@ -785,7 +785,7 @@ class point_space(space): ...@@ -785,7 +785,7 @@ class point_space(space):
Pixel volume of the :py:class:`point_space`, which is always 1. Pixel volume of the :py:class:`point_space`, which is always 1.
""" """
def __init__(self, num, dtype=np.dtype('float'), datamodel='fftw', def __init__(self, num, dtype=np.dtype('float'),
comm=gc['default_comm']): comm=gc['default_comm']):
""" """
Sets the attributes for a point_space class instance. Sets the attributes for a point_space class instance.
...@@ -818,13 +818,6 @@ class point_space(space): ...@@ -818,13 +818,6 @@ class point_space(space):
"WARNING: incompatible dtype: " + str(dtype))) "WARNING: incompatible dtype: " + str(dtype)))
self.dtype = dtype self.dtype = dtype
if datamodel not in POINT_DISTRIBUTION_STRATEGIES:
about._errors.cstring("WARNING: datamodel set to default.")
self.datamodel = \
gc['default_distribution_strategy']
else:
self.datamodel = datamodel
self.comm = self._parse_comm(comm) self.comm = self._parse_comm(comm)
self.discrete = True self.discrete = True
# self.harmonic = False # self.harmonic = False
...@@ -880,7 +873,6 @@ class point_space(space): ...@@ -880,7 +873,6 @@ class point_space(space):
def copy(self): def copy(self):
return point_space(num=self.paradict['num'], return point_space(num=self.paradict['num'],
dtype=self.dtype, dtype=self.dtype,
datamodel=self.datamodel,
comm=self.comm) comm=self.comm)
def getitem(self, data, key): def getitem(self, data, key):
...@@ -1108,13 +1100,8 @@ class point_space(space): ...@@ -1108,13 +1100,8 @@ class point_space(space):
"loss of precision!\n") "loss of precision!\n")
to_copy = True to_copy = True
# Check the distribution_strategy
if x.distribution_strategy != self.datamodel:
to_copy = True
if to_copy: if to_copy:
temp = x.copy_empty(dtype=dtype, temp = x.copy_empty(dtype=dtype)
distribution_strategy=self.datamodel)
temp.set_data(to_key=(slice(None),), temp.set_data(to_key=(slice(None),),
data=x, data=x,
from_key=(slice(None),)) from_key=(slice(None),))
...@@ -1128,8 +1115,7 @@ class point_space(space): ...@@ -1128,8 +1115,7 @@ class point_space(space):
else: else:
x = distributed_data_object(x, x = distributed_data_object(x,
global_shape=self.get_shape(), global_shape=self.get_shape(),
dtype=dtype, dtype=dtype)
distribution_strategy=self.datamodel)
# Cast the d2o # Cast the d2o
return self.cast(x, dtype=dtype) return self.cast(x, dtype=dtype)
...@@ -1327,8 +1313,7 @@ class point_space(space): ...@@ -1327,8 +1313,7 @@ class point_space(space):
# Prepare the empty distributed_data_object # Prepare the empty distributed_data_object
sample = distributed_data_object( sample = distributed_data_object(
global_shape=self.get_shape(), global_shape=self.get_shape(),
dtype=self.dtype, dtype=self.dtype)
distribution_strategy=self.datamodel)
# Case 1: uniform distribution over {-1,+1}/{1,i,-1,-i} # Case 1: uniform distribution over {-1,+1}/{1,i,-1,-i}
if arg['random'] == 'pm1': if arg['random'] == 'pm1':
...@@ -1632,7 +1617,6 @@ class point_space(space): ...@@ -1632,7 +1617,6 @@ class point_space(space):
string += str(type(self)) + "\n" string += str(type(self)) + "\n"
string += "paradict: " + str(self.paradict) + "\n" string += "paradict: " + str(self.paradict) + "\n"
string += 'dtype: ' + str(self.dtype) + "\n" string += 'dtype: ' + str(self.dtype) + "\n"
string += 'datamodel: ' + str(self.datamodel) + "\n"
string += 'comm: ' + self.comm.name + "\n" string += 'comm: ' + self.comm.name + "\n"
string += 'discrete: ' + str(self.discrete) + "\n" string += 'discrete: ' + str(self.discrete) + "\n"
string += 'distances: ' + str(self.distances) + "\n" string += 'distances: ' + str(self.distances) + "\n"
......
...@@ -122,7 +122,7 @@ class rg_space(point_space): ...@@ -122,7 +122,7 @@ class rg_space(point_space):
epsilon = 0.0001 # relative precision for comparisons epsilon = 0.0001 # relative precision for comparisons
def __init__(self, shape, zerocenter=False, complexity=0, distances=None, def __init__(self, shape, zerocenter=False, complexity=0, distances=None,
harmonic=False, datamodel='fftw', fft_module=gc['fft_module'], harmonic=False, fft_module=gc['fft_module'],
comm=gc['default_comm']): comm=gc['default_comm']):
""" """
Sets the attributes for an rg_space class instance. Sets the attributes for an rg_space class instance.
...@@ -163,14 +163,6 @@ class rg_space(point_space): ...@@ -163,14 +163,6 @@ class rg_space(point_space):
else: else:
self.dtype = np.dtype('complex128') self.dtype = np.dtype('complex128')
# set datamodel
if datamodel not in ['np'] + RG_DISTRIBUTION_STRATEGIES:
about.warnings.cprint("WARNING: datamodel set to default.")
self.datamodel = \
gc['default_distribution_strategy']
else:
self.datamodel = datamodel
# set volume/distances # set volume/distances
naxes = len(self.paradict['shape']) naxes = len(self.paradict['shape'])
if distances is None: if distances is None:
...@@ -210,7 +202,6 @@ class rg_space(point_space): ...@@ -210,7 +202,6 @@ class rg_space(point_space):
dgrid=distances, dgrid=distances,
zerocentered=self.paradict['zerocenter'], zerocentered=self.paradict['zerocenter'],
comm=self.comm, comm=self.comm,
datamodel=self.datamodel,
allowed_distribution_strategies=RG_DISTRIBUTION_STRATEGIES) allowed_distribution_strategies=RG_DISTRIBUTION_STRATEGIES)
@property @property
...@@ -257,7 +248,6 @@ class rg_space(point_space): ...@@ -257,7 +248,6 @@ class rg_space(point_space):
zerocenter=self.paradict['zerocenter'], zerocenter=self.paradict['zerocenter'],
distances=self.distances, distances=self.distances,
harmonic=self.harmonic, harmonic=self.harmonic,
datamodel=self.datamodel,
fft_module=self.fft_machine.name, fft_module=self.fft_machine.name,
comm=self.comm) comm=self.comm)
...@@ -376,9 +366,6 @@ class rg_space(point_space): ...@@ -376,9 +366,6 @@ class rg_space(point_space):
raise TypeError(about._errors.cstring( raise TypeError(about._errors.cstring(
"ERROR: The given codomain must be a nifty rg_space.")) "ERROR: The given codomain must be a nifty rg_space."))
if self.datamodel is not codomain.datamodel:
return False
if self.comm is not codomain.comm: if self.comm is not codomain.comm:
return False return False
...@@ -482,7 +469,6 @@ class rg_space(point_space): ...@@ -482,7 +469,6 @@ class rg_space(point_space):
shape = self.paradict['shape'] shape = self.paradict['shape']
distances = 1 / (np.array(self.paradict['shape']) * distances = 1 / (np.array(self.paradict['shape']) *
np.array(self.distances)) np.array(self.distances))
datamodel = self.datamodel
fft_module = self.fft_machine.name fft_module = self.fft_machine.name
comm = self.comm comm = self.comm
complexity = {0: 1, 1: 0, 2: 2}[self.paradict['complexity']] complexity = {0: 1, 1: 0, 2: 2}[self.paradict['complexity']]
...@@ -493,7 +479,6 @@ class rg_space(point_space): ...@@ -493,7 +479,6 @@ class rg_space(point_space):
complexity=complexity, complexity=complexity,
distances=distances, distances=distances,
harmonic=harmonic, harmonic=harmonic,
datamodel=datamodel,
fft_module=fft_module, fft_module=fft_module,
comm=comm) comm=comm)
return new_space return new_space
...@@ -929,8 +914,9 @@ class rg_space(point_space): ...@@ -929,8 +914,9 @@ class rg_space(point_space):
x = self.cast(x) x = self.cast(x)
# if x is hermitian it remains hermitian during smoothing # if x is hermitian it remains hermitian during smoothing
if self.datamodel in RG_DISTRIBUTION_STRATEGIES: # TODO look at this later
remeber_hermitianQ = x.hermitian # if self.datamodel in RG_DISTRIBUTION_STRATEGIES:
remeber_hermitianQ = x.hermitian