def _validate(self, value):

        value_hash = hashlib.md5(value.tostring()).hexdigest()

        if self._validate_cache in value_hash:
            return value

        logger.info("Checking consistency of refined array")

        # Check that refined array reduces to a single False if removing all
        # levels of refinement.
        refined_str = value.tostring()
        previous = ''
        while True:
            refined_str = refined_str.replace(b'\x01\x00\x00\x00\x00\x00\x00\x00\x00', b'\x00')
            if refined_str == previous:
                break
            else:
                previous = refined_str
        if refined_str != b'\x00':
            raise ValueError('refined should reduce to a single False value if removing levels in hierarchy')

        def check_recursive(refined, current_i=0, max_level=0):
            if refined[current_i]:
                current_i += 1
                max_levels = []
                for i in range(8):
                    current_i, max_level_indiv = check_recursive(refined, current_i, max_level+1)
                    max_levels.append(max_level_indiv)
                max_level = max(max_levels)
            else:
                current_i += 1
            return current_i, max_level

        try:
            final_i, max_level = check_recursive(value)
        except IndexError:
            raise ValueError("refined array is not self-consistent")

        logger.info("Setting refined with maximum depth of {0} levels".format(max_level))

        if max_level > 20:
            logger.warn("Number of levels in octree is high ({0})".format(max_level))

        self._validate_cache[value_hash] = True

        return value
dataset/ETHPy150Open hyperion-rt/hyperion/hyperion/grid/octree_grid.py/OctreeGrid._validate/swapped operands of `in`