Exemple #1
0
    def add_child(self, child):
        if self._children_ids is None:
            self._children_ids = -1 * np.ones(
                self._refine_by**self.ds.dimensionality, dtype=np.int64)

        a_block = self.block_name[1:].replace(":", "")
        d_block = child.block_name[1:].replace(":", "")
        cid = get_child_index(a_block, d_block)
        self._children_ids[cid] = child.id
Exemple #2
0
    def get_parent_id(self, desc_block_name):
        if self.block_name == desc_block_name:
            raise RuntimeError("Child and parent are the same!")
        dim = self.ds.dimensionality
        d_block = desc_block_name[1:].replace(":", "")
        parent = self

        while True:
            a_block = parent.block_name[1:].replace(":", "")
            gengap = (len(d_block) - len(a_block)) / dim
            if gengap <= 1:
                return parent.id
            cid = get_child_index(a_block, d_block)
            parent = self.index.grids[parent._children_ids[cid]]