[docs]classLayout:""" Container class for all types of partition data. The layout swaps the data of the partition with temporary layout associated data, and tries out experimental changes to the partition data, if the layout process fails, the original partition data is reinstated. """def__init__(self,data,owner=None,children=None,frozen=False):ifchildrenisNone:children=[]self._data=dataself._owner=ownerself._children=childrenself._frozen=frozen@propertydefdata(self):returnself._data@propertydefchildren(self):returnself._children
[docs]classPartitionData(abc.ABC):""" The partition data is a class that stores the description of a partition for a partition. This allows the Partition interface to define mutating operations such as translate, rotate, scale; for a dry-run we only have to swap out the actual data with temporary data, and the mutation is prevented. """
[docs]classRhomboidData(PartitionData):def__init__(self,ldc,mdc):# Least dominant cornerself.ldc=np.array(ldc,dtype=float,copy=False)# Most dominant cornerself.mdc=np.array(mdc,dtype=float,copy=False)def__repr__(self):returnf"{self.__class__.__name__}({self.ldc}, {self.mdc})"
[docs]defcopy(self):""" Copy this boundary to a new instance. """returnself.__class__(self.ldc.copy(),self.mdc.copy())