generalized split mapper

This commit is contained in:
Matthias Bisping 2022-04-11 13:03:02 +02:00
parent f4c0547405
commit bcf6dc5c47

View File

@ -7,23 +7,22 @@ from image_prediction.info import Info
@dataclass
class SplitMapper:
"""Manages access into a coordinate encoding mapping by abstracting over x1, x2 and y1, y2 as c1, c2; as well as
over width and height as 'dim'."""
__keymap: dict
"""Manages access into a mapping M by indirection through a specified access mapping to achieve a common
interface between various M_i.
"""
__access_mapping: dict
wrapped: dict
__wrapped: dict = field(init=False)
dim: float = field(init=False)
c1: float = field(init=False)
c2: float = field(init=False)
def __post_init__(self):
for k, v in self.__keymap.items():
for k, v in self.__access_mapping.items():
setattr(self, k, self.__wrapped[v])
@property
def wrapped(self):
ret = deepcopy(self.__wrapped)
ret.update(dict(zip(self.__keymap.values(), attrgetter(*self.__keymap.keys())(self))))
ret.update(dict(zip(self.__access_mapping.values(), attrgetter(*self.__access_mapping.keys())(self))))
return ret
@wrapped.setter