transformation.py 841 Bytes
Newer Older
1
2
3

import abc

4
from keepers import Loggable
5

6

7
class Transformation(Loggable, object):
8
    """
Jait Dixit's avatar
Jait Dixit committed
9
10
        A generic transformation which defines a static check_codomain
        method for all transforms.
11
    """
12
    __metaclass__ = abc.ABCMeta
13

14
    def __init__(self, domain, codomain, module=None):
15
16
17
        if codomain is None:
            self.domain = domain
            self.codomain = self.get_codomain(domain)
Theo Steininger's avatar
Theo Steininger committed
18
19
        else:
            self.check_codomain(domain, codomain)
20
21
22
            self.domain = domain
            self.codomain = codomain

23
24
    @classmethod
    def get_codomain(cls, domain, dtype=None, zerocenter=None):
25
26
27
28
29
        raise NotImplementedError

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

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