Find the common dtype for `blocks`.

    Parameters
    ----------
    blocks : List[Block]

    Returns
    -------
    dtype : Optional[Union[np.dtype, ExtensionDtype]]
        None is returned when `blocks` is empty.
195521
def _interleaved_dtype(
        blocks: List[Block]
) -> Optional[Union[np.dtype, ExtensionDtype]]:
    
    if not len(blocks):
        return None

    return find_common_type([b.dtype for b in blocks])
731175
def get_block(self, block_name):
        
        # block_name = [block_name] if isinstance(
        #     block_name, str) else block_name
        # return QA_DataStruct_Stock_block(self.data[self.data.blockname.apply(lambda x: x in block_name)])

        return self.new(self.data.loc[(block_name, slice(None)), :])
408123
function(blocks, type) {

		var result = this.asBlocks(blocks),
			i = 0,
			count = result.length;

		for (; i < count; i++) {

			if (result[i].type != type) Lava.t("Block type is not permitted in this context. Expected: " + type + ", got: " + result[i].type);

		}

		return result;

	}
1301409
def _rule_container(self):
        

        type_name = self._get_token(self.RE_NAME)
        self._expect_token('{')

        # consume elements if available
        options = []
        blocks = []
        dupe_blocks = {}

        while self._lookahead_token() != '}':
            # is it a block?
            if self._lookahead_token(count=2) == '{':
                block = self._rule_block()
                name = block[0]

                # duplicate found, hold for replace
                if name in self._block_map:
                    dupe_blocks[name] = block
                else:
                    # update block index and add to block list
                    self._block_map[name] = len(blocks)
                    blocks.append(block)

            else:
                # otherwise, let's go with non-block option
                options.append(self._rule_option())

        # replace duplicate block definitions
        if dupe_blocks:
            for name, block in dupe_blocks.iteritems():
                block_idx = self._block_map[name]
                blocks[block_idx] = block

        self._expect_token('}')
        self._expect_empty()

        return [type_name, options, blocks]
412333
def build_block(self):
        
        header_bytes = self.block_header.SerializeToString()
        block = Block(header=header_bytes,
                      header_signature=self._header_signature)
        block.batches.extend(self.batches)
        return block
994615
def get_blocks(self):
        

        self.process_triple_quoted_doc_string()

        num_indented_blocks = 0
        for indentation, block in self._blocks:
            if indentation > 0:
                num_indented_blocks += 1
            yield indentation, block

        if self.expects_body_or_pass and num_indented_blocks == 0:
            yield 1, "pass"
            return
379744
def _get_full_block(grouped_dicoms):
    
    # For each slice / mosaic create a data volume block
    data_blocks = []
    for index in range(0, len(grouped_dicoms)):
        logger.info('Creating block %s of %s' % (index + 1, len(grouped_dicoms)))
        data_blocks.append(_timepoint_to_block(grouped_dicoms[index]))

    # Add the data_blocks together to one 4d block
    size_x = numpy.shape(data_blocks[0])[0]
    size_y = numpy.shape(data_blocks[0])[1]
    size_z = numpy.shape(data_blocks[0])[2]
    size_t = len(data_blocks)
    full_block = numpy.zeros((size_x, size_y, size_z, size_t), dtype=data_blocks[0].dtype)
    for index in range(0, size_t):
        if full_block[:, :, :, index].shape != data_blocks[index].shape:
            logger.warning('Missing slices (slice count mismatch between timepoint %s and %s)' % (index - 1, index))
            logger.warning('---------------------------------------------------------')
            logger.warning(full_block[:, :, :, index].shape)
            logger.warning(data_blocks[index].shape)
            logger.warning('---------------------------------------------------------')
            raise ConversionError("MISSING_DICOM_FILES")
        full_block[:, :, :, index] = data_blocks[index]

    return full_block
10154
def is_uniform_join_units(join_units):
    
    return (
        # all blocks need to have the same type
        all(type(ju.block) is type(join_units[0].block) for ju in join_units) and  # noqa
        # no blocks that would get missing values (can lead to type upcasts)
        # unless we're an extension dtype.
        all(not ju.is_na or ju.block.is_extension for ju in join_units) and
        # no blocks with indexers (as then the dimensions do not fit)
        all(not ju.indexers for ju in join_units) and
        # disregard Panels
        all(ju.block.ndim <= 2 for ju in join_units) and
        # only use this path when there is something to concatenate
        len(join_units) > 1)
937436
def _consolidate(blocks):
    

    # sort by _can_consolidate, dtype
    gkey = lambda x: x._consolidate_key
    grouper = itertools.groupby(sorted(blocks, key=gkey), gkey)

    new_blocks = []
    for (_can_consolidate, dtype), group_blocks in grouper:
        merged_blocks = _merge_blocks(list(group_blocks), dtype=dtype,
                                      _can_consolidate=_can_consolidate)
        new_blocks = _extend_blocks(merged_blocks, new_blocks)
    return new_blocks
1366307
def check_matching_blocks(*arrays):
    
    if len(arrays) <= 1:
        return
    if all(isinstance(x, da.Array) for x in arrays):
        # TODO: unknown chunks, ensure blocks match, or just raise (configurable)
        chunks = arrays[0].chunks
        for array in arrays[1:]:
            if array.chunks != chunks:
                raise ValueError(
                    "Mismatched chunks. {} != {}".format(chunks, array.chunks)
                )

    elif all(isinstance(x, (dd.Series, dd.DataFrame)) for x in arrays):
        divisions = arrays[0].divisions
        for array in arrays[1:]:
            if array.divisions != divisions:
                raise ValueError(
                    "Mismatched divisions. {} != {}".format(divisions, array.divisions)
                )
    else:
        raise ValueError("Unexpected types {}.".format({type(x) for x in arrays}))
863216
def get_block(self, block_identifier: BlockSpecification) -> Dict:
        """"""
        return self.web3.eth.getBlock(block_identifier)
671152
def get_nested_blocks_spec(self):
        
        return [
            block_spec if isinstance(block_spec, NestedXBlockSpec) else NestedXBlockSpec(block_spec)
            for block_spec in self.allowed_nested_blocks
        ]
749921
public BlockInfo[] getSourceBlocks(BlockInfo[] blocks) {
    int numSourceBlocks = blocks.length - 
        (blocks.length / numStripeBlocks) * numParityBlocks - 
        ((blocks.length % numStripeBlocks == 0) ? 0 : numParityBlocks);
    BlockInfo[] sourceBlocks = new BlockInfo[numSourceBlocks];
    int pos = numParityBlocks;
    int stripeEnd = numStripeBlocks;
    for (int i = 0; i < numSourceBlocks; i++) {
      sourceBlocks[i] = blocks[pos];
      pos++;
      if (pos == stripeEnd) {
        pos += numParityBlocks;
        stripeEnd += numStripeBlocks;
      }
    }
    return sourceBlocks;
  }
280481
def _expand_block(cls, block):
        
        cls._parse_header(BlockHeader, block)
        if 'batches' in block:
            block['batches'] = [cls._expand_batch(b) for b in block['batches']]
        return block
755589
def _block_shape(values, ndim=1, shape=None):
    
    if values.ndim < ndim:
        if shape is None:
            shape = values.shape
        if not is_extension_array_dtype(values):
            # TODO: https://github.com/pandas-dev/pandas/issues/23023
            # block.shape is incorrect for "2D" ExtensionArrays
            # We can't, and don't need to, reshape.
            values = values.reshape(tuple((1, ) + shape))
    return values
640165
def get_block_type(self, def_id):
        """"""
        try:
            return self._definitions[def_id]
        except KeyError:
            try:
                return def_id.aside_type
            except AttributeError:
                raise NoSuchDefinition(repr(def_id))
345741
def get_block(self, config_only=False):
        """"""

        mib = TBBlock()

        for cid, config in self.configs.items():
            mib.add_config(cid, config)

        if not config_only:
            for key, val in self.commands.items():
                mib.add_command(key, val)

            if not self.valid:
                self._validate_information()

            mib.set_api_version(*self.variables["APIVersion"])
            mib.set_module_version(*self.variables["ModuleVersion"])
            mib.set_name(self.variables["ModuleName"])

        return mib