Commit a13e0bdb authored by theos's avatar theos
Browse files

removed discrete attribute from spaces and operators

parent 9a4ea2b4
......@@ -114,7 +114,6 @@ class GLSpace(Space):
dtype = np.dtype('float')
self.dtype = dtype
self.discrete = False
self.harmonic = False
self.distances = (tuple(gl.vol(self.paradict['nlat'],
nlon=self.paradict['nlon']
......@@ -310,9 +309,6 @@ class GLSpace(Space):
sample = gl.synfast(arg['spec'],
nlat=nlat, nlon=nlon,
lmax=lmax, mmax=lmax, alm=False)
# weight if discrete
if self.discrete:
sample = self.calc_weight(sample, power=0.5)
else:
sample = super(GLSpace, self).get_random_values(**arg)
......@@ -413,9 +409,6 @@ class GLSpace(Space):
if isinstance(codomain, LMSpace):
# weight if discrete
if self.discrete:
x = self.calc_weight(x, power=-0.5)
# transform
nlat = self.paradict['nlat']
nlon = self.paradict['nlon']
......@@ -503,9 +496,7 @@ class GLSpace(Space):
Power contained in the input array.
"""
x = self.cast(x)
# weight if discrete
if self.discrete:
x = self.calc_weight(x, power=-0.5)
# calculate the power spectrum
nlat = self.paradict['nlat']
nlon = self.paradict['nlon']
......
......@@ -137,7 +137,6 @@ class HPSpace(Space):
self.dtype = np.dtype('float64')
self.discrete = False
self.harmonic = False
self.distances = (np.float(4*np.pi / (12*self.paradict['nside']**2)),)
......@@ -310,9 +309,6 @@ class HPSpace(Space):
lmax=lmax, mmax=lmax,
alm=False, pol=True, pixwin=False,
fwhm=0.0, sigma=None)
# weight if discrete
if self.discrete:
sample = self.calc_weight(sample, power=0.5)
else:
sample = super(HPSpace, self).get_random_values(**arg)
......@@ -373,9 +369,6 @@ class HPSpace(Space):
np_x = x.get_full_data()
if isinstance(codomain, LMSpace):
# weight if discrete
if self.discrete:
x = self.calc_weight(x, power=-0.5)
# transform
np_Tx = hp.map2alm(np_x.astype(np.float64, copy=False),
lmax=codomain.paradict['lmax'],
......@@ -464,9 +457,6 @@ class HPSpace(Space):
transformation.
"""
x = self.cast(x)
# weight if discrete
if self.discrete:
x = self.calc_weight(x, power=-0.5)
nside = self.paradict['nside']
lmax = 3*nside-1
......
......@@ -129,7 +129,6 @@ class LMSpace(Space):
dtype = np.dtype('complex128')
self.dtype = dtype
self.discrete = True
self.harmonic = True
self.distances = (np.float(1),)
......@@ -564,10 +563,6 @@ class LMSpace(Space):
raise ValueError(about._errors.cstring(
"ERROR: unsupported transformation."))
# re-weight if discrete
if codomain.discrete:
Tx = codomain.calc_weight(Tx, power=0.5)
return codomain.cast(Tx)
def calc_smooth(self, x, sigma=0, **kwargs):
......
......@@ -138,7 +138,7 @@ class operator(object):
None
"""
# Check if the domain is realy a space
if not isinstance(domain, space):
if not isinstance(domain, Space):
raise TypeError(about._errors.cstring(
"ERROR: invalid input. domain is not a space."))
self.domain = domain
......@@ -167,7 +167,7 @@ class operator(object):
target = self.domain
cotarget = self.codomain
elif isinstance(target, space):
elif isinstance(target, Space):
self.target = target
# Parse cotarget
if self.target.check_codomain(cotarget) == True:
......@@ -178,10 +178,7 @@ class operator(object):
raise TypeError(about._errors.cstring(
"ERROR: invalid input. Target is not a space."))
if self.domain.discrete and self.target.discrete:
self.imp = True
else:
self.imp = bool(imp)
self.imp = bool(imp)
def set_val(self, new_val):
"""
......@@ -231,7 +228,7 @@ class operator(object):
copy=False)
# weight if necessary
if (not self.imp) and (not domain.discrete) and (not inverse):
if (not self.imp) and (not inverse):
result_field = result_field.weight(power=1)
return result_field
......@@ -241,7 +238,7 @@ class operator(object):
assert(isinstance(y, Field))
# weight if necessary
if (not self.imp) and (not target.discrete) and inverse:
if (not self.imp) and inverse:
y = y.weight(power=-1)
# if the operators domain as well as the target have the harmonic
......@@ -580,7 +577,7 @@ class operator(object):
if domain is None:
domain = diag.domain
# weight if ...
if (not domain.discrete) and bare:
if and bare:
if(isinstance(diag, tuple)): # diag == (diag,variance)
return (diag[0].weight(power=-1),
diag[1].weight(power=-1))
......@@ -672,7 +669,7 @@ class operator(object):
if domain is None:
domain = diag.codomain
# weight if ...
if not domain.discrete and bare:
if bare:
if(isinstance(diag, tuple)): # diag == (diag,variance)
return (diag[0].weight(power=-1),
diag[1].weight(power=-1))
......@@ -1165,7 +1162,7 @@ class diagonal_operator(operator):
self.bare = bare
# Weight if necessary
if not self.domain.discrete and bare:
if bare:
self.val = self.domain.calc_weight(self.val, power=1)
# Check complexity attributes
......@@ -1398,7 +1395,7 @@ class diagonal_operator(operator):
"""
if (domain is None) or (domain == self.domain):
if not self.domain.discrete and bare:
if bare:
diag_val = self.domain.calc_weight(self.val, power=-1)
else:
diag_val = self.val
......@@ -1485,7 +1482,7 @@ class diagonal_operator(operator):
if (domain is None) or (domain == self.domain):
inverse_val = 1. / self.val
if not self.domain.discrete and bare:
if bare:
inverse_diag_val = self.domain.calc_weight(inverse_val,
power=-1)
else:
......@@ -1908,7 +1905,7 @@ class power_operator(diagonal_operator):
diag = temp_spec[pindex]
# Weight if necessary
if not self.domain.discrete and bare:
if bare:
self.val = self.domain.calc_weight(diag, power=1)
else:
self.val = diag
......@@ -1986,7 +1983,7 @@ class power_operator(diagonal_operator):
temp_kwargs.update(kwargs)
# Weight the diagonal values if necessary
if not self.domain.discrete and bare:
if bare:
diag = self.domain.calc_weight(self.val, power=-1)
else:
diag = self.val
......@@ -2641,7 +2638,7 @@ class vecvec_operator(operator):
if domain is None or (domain == self.domain):
diag_val = self.val * self.val.conjugate() # bare diagonal
# weight if ...
if not self.domain.discrete and not bare:
if not bare:
diag_val = diag_val.weight(power=1, overwrite=True)
return diag_val
else:
......@@ -2849,9 +2846,6 @@ class response_operator(operator):
if not isinstance(target, Space):
raise TypeError(about._errors.cstring(
"ERROR: Given target is not a nifty space"))
elif not target.discrete:
raise ValueError(about._errors.cstring(
"ERROR: Given target must be a discrete space!"))
elif len(target.shape) > 1:
raise ValueError(about._errors.cstring(
"ERROR: Given target must be a one-dimensional space."))
......@@ -2942,7 +2936,7 @@ class response_operator(operator):
copy=False)
# weight if necessary
if (not self.imp) and (not domain.discrete) and (not inverse) and \
if (not self.imp) and (not inverse) and \
self.den:
result_field = result_field.weight(power=1)
return result_field
......@@ -2953,8 +2947,7 @@ class response_operator(operator):
assert(isinstance(y, Field))
# weight if necessary
if (not self.imp) and (not target.discrete) and \
(not self.den ^ inverse):
if (not self.imp) and (not self.den ^ inverse):
y = y.weight(power=-1)
return y
......@@ -3080,10 +3073,7 @@ class invertible_operator(operator):
self.sym = True
self.uni = bool(uni)
if(self.domain.discrete):
self.imp = True
else:
self.imp = bool(imp)
self.imp = bool(imp)
self.target = self.domain
self.cotarget = self.codomain
......
......@@ -30,7 +30,6 @@ class RGPowerSpace(PowerSpace):
self.distances = (tuple(self.power_indices['rho']),)
self.harmonic = True
self.discrete = False
@property
def shape(self):
......
......@@ -168,7 +168,6 @@ class RGSpace(Space):
self.distances = distances
self.harmonic = bool(harmonic)
self.discrete = False
# Initializes the fast-fourier-transform machine, which will be used
# to transform the space
......
......@@ -220,7 +220,6 @@ class Space(object):
"WARNING: incompatible dtype: " + str(dtype)))
self.dtype = dtype
self.discrete = None
self.harmonic = None
self._distances = None
......@@ -874,6 +873,5 @@ class Space(object):
string += str(type(self)) + "\n"
string += "paradict: " + str(self.paradict) + "\n"
string += 'dtype: ' + str(self.dtype) + "\n"
string += 'discrete: ' + str(self.discrete) + "\n"
string += 'distances: ' + str(self.distances) + "\n"
return string
......@@ -290,7 +290,6 @@ class Test_Common_Point_Like_Space_Interface(unittest.TestCase):
assert(isinstance(s.paradict, space_paradict))
assert(isinstance(s.paradict, space_paradict))
assert(isinstance(s.dtype, np.dtype))
assert(isinstance(s.discrete, bool))
# assert(isinstance(s.harmonic, bool))
assert(isinstance(s.distances, tuple))
if hasattr(s, 'harmonic'):
......@@ -340,7 +339,6 @@ class Test_Point_Space(unittest.TestCase):
assert_equal(p.paradict['num'], num)
assert_equal(p.dtype, dtype)
assert_equal(p.discrete, True)
assert_equal(p.distances, (np.float(1.),))
###############################################################################
......@@ -992,7 +990,6 @@ class Test_Lm_Space(unittest.TestCase):
else:
assert_equal(l.paradict['mmax'], mmax)
assert_equal(l.dtype, dtype)
assert_equal(l.discrete, True)
assert_equal(l.harmonic, True)
assert_equal(l.distances, (np.float(1),))
else:
......
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