space.py 2.75 KB
Newer Older
1
2
3
4
5
# NIFTy
# Copyright (C) 2017  Theo Steininger
#
# Author: Theo Steininger
#
6
7
8
9
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
10
#
11
12
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
14
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Marco Selig's avatar
Marco Selig committed
18

19
20
import abc

21
from nifty.domain_object import DomainObject
Theo Steininger's avatar
Theo Steininger committed
22

23

24
class Space(DomainObject):
25
    """The abstract base class for all NIFTy spaces.
Marco Selig's avatar
Marco Selig committed
26

27
28
29
    An instance of a space contains information about the manifolds geometry
    and enhances the functionality of DomainObject by methods that are needed
    for powerspectrum analysis and smoothing.
30

Theo Steininger's avatar
Theo Steininger committed
31
32
            Parameters
            ----------
33
    None
Marco Selig's avatar
Marco Selig committed
34

35
36
37
38
39
40
41
42
43
44
    Attributes
    ----------
    dim : np.int
        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.
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
    Raises
    ------
    TypeError
        Raised if instantiated directly.

    Notes
    -----
    `Space` is an abstract base class. In order to allow for instantiation the
    methods `get_distance_array`, `total_volume` and `copy` must be implemented
    as well as the abstract methods inherited from `DomainObject`.

    See Also
    --------
    distributor
60
        """
61
    def __init__(self):
Martin Reinecke's avatar
Martin Reinecke committed
62
        super(Space, self).__init__()
63

64
65
66
    @abc.abstractproperty
    def harmonic(self):
        raise NotImplementedError
67

68
    @abc.abstractproperty
69
    def total_volume(self):
70
71
        raise NotImplementedError(
            "There is no generic volume for the Space base class.")
72

73
74
    @abc.abstractmethod
    def copy(self):
Martin Reinecke's avatar
Martin Reinecke committed
75
        return self.__class__()
76

77
    def get_distance_array(self, distribution_strategy):
78
        raise NotImplementedError(
79
80
            "There is no generic distance structure for Space base class.")

81
    def get_fft_smoothing_kernel_function(self, sigma):
82
83
        raise NotImplementedError(
            "There is no generic co-smoothing kernel for Space base class.")
84

85
86
    def hermitian_decomposition(self, x, axes=None,
                                preserve_gaussian_variance=False):
87
88
        raise NotImplementedError

89
    def __repr__(self):
Theo Steininger's avatar
Theo Steininger committed
90
91
92
        string = ""
        string += str(type(self)) + "\n"
        return string