(self, other, replacements=None)
return self
Merge another KeyedRegion into this KeyedRegion.

        :param KeyedRegion other: The other instance to merge with.
        :return: None
Merge another KeyedRegion into this KeyedRegion.
Merge another KeyedRegion into this KeyedRegion .
def merge(self, other, replacements=None):
        """
        Merge another KeyedRegion into this KeyedRegion.

        :param KeyedRegion other: The other instance to merge with.
        :return: None
        """

        if self._canonical_size != other._canonical_size:
            raise ValueError("The canonical sizes of two KeyedRegion objects must equal.")

        # TODO: is the current solution not optimal enough?
        for _, item in other._storage.items():  # type: RegionObject
            for so in item.stored_objects:  # type: StoredObject
                if replacements and so.obj in replacements:
                    so = StoredObject(so.start, replacements[so.obj], so.size)
                self._object_mapping[so.obj_id] = so
                self.__store(so, overwrite=False)

        return self
def merge ( self , other , replacements = None ) : if self . _canonical_size != other . _canonical_size : raise ValueError ( "The canonical sizes of two KeyedRegion objects must equal." ) # TODO: is the current solution not optimal enough? for _ , item in other . _storage . items ( ) : # type: RegionObject for so in item . stored_objects : # type: StoredObject if replacements and so . obj in replacements : so = StoredObject ( so . start , replacements [ so . obj ] , so . size ) self . _object_mapping [ so . obj_id ] = so self . __store ( so , overwrite = False ) return self