Passed
Push — dev ( 6a1e3c...3c73d5 )
by Konstantinos
01:31
created

AbstractFeatureFactory.get_feature()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 3
1
from abc import ABC, abstractmethod
2
3
from data.features.features import TrackingFeature
4
5
6
class AbstractFeatureFactory(ABC):
7
    @abstractmethod
8
    def get_feature(self, *args, **kwargs) -> TrackingFeature:
9
        raise NotImplementedError
10
11
12
class FeatureFactory(AbstractFeatureFactory):
13
14
    @classmethod
15
    def register_as_subclass(cls, backend_type):
16
        def wrapper(subclass):
17
            cls.subclasses[backend_type] = subclass
18
            return subclass
19
20
        return wrapper
21
22
    @classmethod
23
    def create(cls, backend_type, *args, **kwargs):
24
        if backend_type not in cls.subclasses:
25
            raise ValueError('Bad "BinnerFactory Backend type" type \'{}\''.format(backend_type))
26
        return cls.subclasses[backend_type](*args, **kwargs)
27
28
    def get_feature(self, *args, **kwargs) -> TrackingFeature:
29
        raise NotImplementedError
30