field_type.py 734 Bytes
Newer Older
Theo Steininger's avatar
Theo Steininger committed
1
2
# -*- coding: utf-8 -*-

3
from nifty.domain_object import DomainObject
Theo Steininger's avatar
Theo Steininger committed
4
5


6
class FieldType(DomainObject):
Theo Steininger's avatar
Theo Steininger committed
7

8
9
10
11
12
13
14
    def weight(self, x, power=1, axes=None, inplace=False):
        if inplace:
            result = x
        else:
            result = x.copy()
        return result

Theo Steininger's avatar
Theo Steininger committed
15
16
17
18
19
20
21
22
23
24
25
26
    def process(self, method_name, array, inplace=True, **kwargs):
        try:
            result_array = self.__getattr__(method_name)(array,
                                                         inplace,
                                                         **kwargs)
        except AttributeError:
            if inplace:
                result_array = array
            else:
                result_array = array.copy()

        return result_array