transformation.py 1.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# NIFTy
# Copyright (C) 2017  Theo Steininger
#
# Author: Theo Steininger
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
20

import abc

21
from keepers import Loggable
22

23

24
class Transformation(Loggable, object):
25
    """
Jait Dixit's avatar
Jait Dixit committed
26
27
        A generic transformation which defines a static check_codomain
        method for all transforms.
28
    """
29
    __metaclass__ = abc.ABCMeta
30

31
    def __init__(self, domain, codomain, module=None):
32
33
34
        if codomain is None:
            self.domain = domain
            self.codomain = self.get_codomain(domain)
Theo Steininger's avatar
Theo Steininger committed
35
36
        else:
            self.check_codomain(domain, codomain)
37
38
39
            self.domain = domain
            self.codomain = codomain

40
41
    @classmethod
    def get_codomain(cls, domain, dtype=None, zerocenter=None):
42
43
44
45
46
        raise NotImplementedError

    @staticmethod
    def check_codomain(domain, codomain):
        raise NotImplementedError
47

Jait Dixit's avatar
Jait Dixit committed
48
49
    def transform(self, val, axes=None, **kwargs):
        raise NotImplementedError