Commit 9734d7db authored by Martin Reinecke's avatar Martin Reinecke

byebye total_volume

parent dfdfff76
Pipeline #19136 canceled with stage
......@@ -379,15 +379,6 @@ class Field(object):
"""
return self.domain.dim
@property
def total_volume(self):
""" Returns the total volume of all spaces in the domain.
"""
if len(self.domain) == 0:
return 0.
volume_tuple = tuple(sp.total_volume for sp in self.domain)
return reduce(lambda x, y: x * y, volume_tuple)
@property
def real(self):
""" The real part of the field (data is not copied).
......
......@@ -52,8 +52,6 @@ class GLSpace(Space):
pixelization.
nlon : int
Number of longitudinal bins that are used for this pixelization.
total_volume : np.float
The total volume of the space.
shape : tuple of np.ints
The shape of the space's data array.
......@@ -105,10 +103,6 @@ class GLSpace(Space):
def dim(self):
return np.int((self.nlat * self.nlon))
@property
def total_volume(self):
return 4 * np.pi
def scalar_dvol(self):
return None
......
......@@ -49,8 +49,6 @@ class HPSpace(Space):
nside : int
The corresponding HEALPix pixelization. The total number of pixels
is 12*nside**2.
total_volume : np.float
The total volume of the space.
shape : tuple of np.ints
The shape of the space's data array.
......@@ -100,10 +98,6 @@ class HPSpace(Space):
def dim(self):
return np.int(12 * self.nside * self.nside)
@property
def total_volume(self):
return 4 * np.pi
def scalar_dvol(self):
return np.pi / (3*self._nside*self._nside)
......
......@@ -53,8 +53,6 @@ class LMSpace(Space):
Total number of dimensionality, i.e. the number of pixels.
harmonic : bool
Specifies whether the space is a signal or harmonic space.
total_volume : np.float
The total volume of the space.
shape : tuple of np.ints
The shape of the space's data array.
......@@ -109,11 +107,6 @@ class LMSpace(Space):
# We fix l == m
return np.int((l+1)*(l+1))
@property
def total_volume(self):
# the individual pixels have a fixed volume of 1.
return np.float64(self.dim)
def scalar_dvol(self):
return 1.
......
......@@ -57,8 +57,6 @@ class PowerSpace(Space):
Total number of dimensionality, i.e. the number of pixels.
harmonic : bool
Always True for this space.
total_volume : np.float
The total volume of the space.
shape : tuple of np.ints
The shape of the space's data array.
binbounds : tuple or None
......@@ -199,11 +197,6 @@ class PowerSpace(Space):
def dim(self):
return self.shape[0]
@property
def total_volume(self):
# every power-pixel has a volume of 1
return float(reduce(lambda x, y: x*y, self.pindex.shape))
def scalar_dvol(self):
return None
......
......@@ -71,8 +71,6 @@ class RGSpace(Space):
Total number of dimensionality, i.e. the number of pixels.
harmonic : bool
Specifies whether the space is a signal or harmonic space.
total_volume : np.float
The total volume of the space.
shape : tuple of np.ints
The shape of the space's data array.
......@@ -106,10 +104,6 @@ class RGSpace(Space):
def dim(self):
return self._dim
@property
def total_volume(self):
return self.dim * self._dvol
def scalar_dvol(self):
return self._dvol
......
......@@ -38,8 +38,6 @@ class Space(DomainObject):
Total number of dimensionality, i.e. the number of pixels.
harmonic : bool
Specifies whether the space is a signal or harmonic space.
total_volume : np.float
The total volume of the space.
shape : tuple of np.ints
The shape of the space's data array.
......@@ -51,8 +49,8 @@ class Space(DomainObject):
Notes
-----
`Space` is an abstract base class. In order to allow for instantiation
the methods `total_volume` and `copy` must be implemented as well as the
abstract methods inherited from `DomainObject`.
the method `copy` must be implemented as well as the abstract methods
inherited from `DomainObject`.
"""
......@@ -65,18 +63,6 @@ class Space(DomainObject):
"""
raise NotImplementedError
@abc.abstractproperty
def total_volume(self):
""" Returns the total volume of the space.
Returns
-------
float
A real number representing the sum of all pixel volumes.
"""
raise NotImplementedError(
"There is no generic volume for the Space base class.")
def get_k_length_array(self):
""" The length of the k vector for every pixel.
This method is only implemented for harmonic spaces.
......
......@@ -45,8 +45,7 @@ class Test_Interface(unittest.TestCase):
[['domain', DomainTuple],
['val', np.ndarray],
['shape', tuple],
['dim', (np.int, np.int64)],
['total_volume', np.float]]))
['dim', (np.int, np.int64)]]))
def test_return_types(self, domain, attribute_desired_type):
attribute = attribute_desired_type[0]
desired_type = attribute_desired_type[1]
......
......@@ -33,7 +33,6 @@ CONSTRUCTOR_CONFIGS = [
'harmonic': False,
'shape': (6,),
'dim': 6,
'total_volume': 4 * np.pi
}],
[0, None, {
'error': ValueError
......
......@@ -32,21 +32,18 @@ CONSTRUCTOR_CONFIGS = [
'harmonic': False,
'shape': (48,),
'dim': 48,
'total_volume': 4 * np.pi,
}],
[5, {
'nside': 5,
'harmonic': False,
'shape': (300,),
'dim': 300,
'total_volume': 4 * np.pi,
}],
[1, {
'nside': 1,
'harmonic': False,
'shape': (12,),
'dim': 12,
'total_volume': 4 * np.pi,
}],
[0, {
'error': ValueError
......
......@@ -31,8 +31,7 @@ class SpaceInterfaceTests(unittest.TestCase):
@expand(product(generate_spaces(), [
['harmonic', bool],
['shape', tuple],
['dim', int],
['total_volume', np.float]]))
['dim', int]]))
def test_property_ret_type(self, space, attr_expected_type):
assert_(isinstance(getattr(space, attr_expected_type[0]),
attr_expected_type[1]))
......
......@@ -33,7 +33,6 @@ CONSTRUCTOR_CONFIGS = [
'shape': (36,),
'harmonic': True,
'dim': 36,
'total_volume': 36.0,
}],
[7, {
'lmax': 7,
......@@ -41,7 +40,6 @@ CONSTRUCTOR_CONFIGS = [
'shape': (64,),
'harmonic': True,
'dim': 64,
'total_volume': 64.0,
}],
[-1, {
'error': ValueError
......
......@@ -52,7 +52,6 @@ CONSTRUCTOR_CONFIGS = [
'harmonic': True,
'shape': (5,),
'dim': 5,
'total_volume': 8.0,
'harmonic_partner': RGSpace((8,), harmonic=True),
'binbounds': None,
'pindex': np.array([0, 1, 2, 3, 4, 3, 2, 1]),
......@@ -63,7 +62,6 @@ CONSTRUCTOR_CONFIGS = [
'harmonic': True,
'shape': (4,),
'dim': 4,
'total_volume': 8.0,
'harmonic_partner': RGSpace((8,), harmonic=True),
'binbounds': (0.5, 1.3228756555322954, 3.5),
'pindex': np.array([0, 1, 2, 2, 3, 2, 2, 1]),
......
......@@ -36,7 +36,6 @@ CONSTRUCTOR_CONFIGS = [
'distances': (0.125,),
'harmonic': False,
'dim': 8,
'total_volume': 1.0
}],
[(8,), None, True,
{
......@@ -44,7 +43,6 @@ CONSTRUCTOR_CONFIGS = [
'distances': (1.0,),
'harmonic': True,
'dim': 8,
'total_volume': 8.0
}],
[(8,), (12,), True,
{
......@@ -52,7 +50,6 @@ CONSTRUCTOR_CONFIGS = [
'distances': (12.0,),
'harmonic': True,
'dim': 8,
'total_volume': 96.0
}],
[(11, 11), None, False,
{
......@@ -60,7 +57,6 @@ CONSTRUCTOR_CONFIGS = [
'distances': (1/11, 1/11),
'harmonic': False,
'dim': 121,
'total_volume': 1.0
}],
[(12, 12), (1.3, 1.3), True,
{
......@@ -68,7 +64,6 @@ CONSTRUCTOR_CONFIGS = [
'distances': (1.3, 1.3),
'harmonic': True,
'dim': 144,
'total_volume': 243.36
}]
]
......
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