Converts [(Key, block)] to [BlockAggregate]
        :param blocks: List of (Key, block) blocks.
        :return: List of BlockAggregate
199461
def _load_blocks(self, blocks: List[Tuple[Key, Any]]) -> List[TimeAggregate]:
        
        return [
            TypeLoader.load_item(self._schema.source.type)(self._schema.source, self._identity,
                                                           EvaluationContext()).run_restore(block)
            for (_, block) in blocks
        ]
106891
def _get_block_transactions(
            self,
            transaction_root: Hash32,
            transaction_class: Type['BaseTransaction']) -> Iterable['BaseTransaction']:
        
        for encoded_transaction in self._get_block_transaction_data(self.db, transaction_root):
            yield rlp.decode(encoded_transaction, sedes=transaction_class)
1369428
def _blockedPairs(self, blocks):
        

        block, blocks = core.peek(blocks)
        self._checkBlock(block)

        combinations = itertools.combinations

        pairs = (combinations(sorted(block), 2) for block in blocks)

        return pairs
388780
def mine_block(self, *args: Any, **kwargs: Any) -> BaseBlock:
        
        mined_block = self.get_vm(self.header).mine_block(*args, **kwargs)

        self.validate_block(mined_block)

        self.chaindb.persist_block(mined_block)
        self.header = self.create_header_from_parent(mined_block.header)
        return mined_block
1316706
def build_command_groups(self, block):
        
        text = block['text']

        commands = sorted(self.build_commands(block))
        grouped = groupby(commands, Command.key)
        listed = list(groupby(commands, Command.key))
        sliced = []

        i = 0
        for start_index, commands in grouped:
            if i < len(listed) - 1:
                stop_index = listed[i + 1][0]
                sliced.append((text[start_index:stop_index], list(commands)))
            else:
                sliced.append((text[start_index:start_index], list(commands)))
            i += 1

        return sliced
1328633
public BlockInfo[] getParityBlocks(BlockInfo[] blocks) {
    int numBlocks = (blocks.length / numStripeBlocks) * numParityBlocks
        + ((blocks.length % numStripeBlocks == 0) ? 0 : numParityBlocks);
    BlockInfo[] parityBlocks = new BlockInfo[numBlocks];
    int pos = 0;
    int parityEnd = numParityBlocks;
    for (int i = 0; i < numBlocks; i++) {
      parityBlocks[i] = blocks[pos];
      pos++;
      if (pos == parityEnd) {
        pos += numDataBlocks;
        parityEnd += numStripeBlocks;
      }
    }
    return parityBlocks;
  }
760332
def differing_blocks(self):
        
        differing_blocks = []
        for (block_a, block_b) in self._block_matches:
            if not self.blocks_probably_identical(block_a, block_b):
                differing_blocks.append((block_a, block_b))
        return differing_blocks
888811
def processing_blocks(self):
        
        sbi_ids = Subarray(self.get_name()).sbi_ids
        pbs = []
        for sbi_id in sbi_ids:
            sbi = SchedulingBlockInstance(sbi_id)
            pbs.append(sbi.processing_block_ids)
        return 'PB', pbs
274251
def previous_blocks(self, quantity=-1):
        """"""
        blocks = (EighthBlock.objects.get_blocks_this_year().order_by(
            "-date", "-block_letter").filter(Q(date__lt=self.date) | (Q(date=self.date) & Q(block_letter__lt=self.block_letter))))
        if quantity == -1:
            return reversed(blocks)
        return reversed(blocks[:quantity])
771162
def set_blocks(self, list=None, dict=None, fill_air=False):
        
        if list:
            # Inputting a list like self.blocksList
            self.blocksList = list
        elif dict:
            # Inputting a dictionary like result of self.get_blocks_struct()
            list = []
            for x in range(16):
                for z in range(16):
                    for y in range(128):
                        coord = x,y,z
                        offset = y + z*128 + x*128*16
                        if (coord in dict):
                            list.append(dict[coord])
                        else:
                            if (self.blocksList[offset] and not fill_air):
                                list.append(self.blocksList[offset])
                            else:
                                list.append(0) # Air
            self.blocksList = list
        else:
            # None of the above...
            return False
        return True
1340705
def iter_blocks(block_list):
        
        # queue the block and the depth of the block
        queue = [(block, 0) for block in block_list
                 if isinstance(block, kurt.Block)]
        while queue:
            block, depth = queue.pop(0)
            assert block.type.text
            yield block.type.text, depth, block
            for arg in block.args:
                if hasattr(arg, '__iter__'):
                    queue[0:0] = [(x, depth + 1) for x in arg
                                  if isinstance(x, kurt.Block)]
                elif isinstance(arg, kurt.Block):
                    queue.append((arg, depth))
434040
def _singleframe_to_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)))
        current_block = _stack_to_block(grouped_dicoms[index])
        current_block = current_block[:, :, :, numpy.newaxis]
        data_blocks.append(current_block)

    try:
        full_block = numpy.concatenate(data_blocks, axis=3)
    except:
        traceback.print_exc()
        raise ConversionError("MISSING_DICOM_FILES")

    # Apply the rescaling if needed
    common.apply_scaling(full_block, grouped_dicoms[0][0])

    return full_block
1014357
def dumpBlock(self, block_name):
        
        if '%' in block_name or '*' in block_name:
            msg = "No wildcard is allowed in block_name for dumpBlock API"
            dbsExceptionHandler('dbsException-invalid-input', msg, self.logger.exception)

        conn = self.dbi.connection()
        try :
            #block name is unique
            block1 = self.blocklist.execute(conn, block_name=block_name)
            block = []
            for b1 in block1:
		if not b1:
		    return {}
		else:
		    block = b1
            #a block only has one dataset and one primary dataset
            #in order to reduce the number of dao objects, we will not write
            #a special migration one. However, we will have to remove the
            #extras
            #block1 is a generator. When it is empty, it will skip the for loop above. why? 
            #we cannot test on b1 to decide if the generator is empty or not.
            #so have to do below:
            if not block: return {}
            dataset1 = self.datasetlist.execute(conn,
                      dataset=block["dataset"], dataset_access_type="")
	    dataset = []
            for d in dataset1:
		if d:
		    dataset = d
		    dconfig_list = self.outputCoflist.execute(conn, dataset=dataset['dataset'])
                else: return {}
            #get block parentage
            bparent = self.blockparentlist.execute(conn, block['block_name'])
            #get dataset parentage
            dsparent = self.dsparentlist.execute(conn, dataset['dataset'])
            for p in dsparent:
                del p['parent_dataset_id']
                if 'dataset'in p:
                    del p['dataset']
                elif 'this_dataset' in p:
                    del p['this_dataset']
                else:
                    pass

            fparent_list = self.fplist.execute(conn,
                                               block_id=block['block_id'])
	    fparent_list2 = [] 	
	    for fp in fparent_list:
		fparent_list2.append(fp)	
	    #print "---YG file Parent List--"
	    #print fparent_list2	
            fconfig_list = self.outputCoflist.execute(conn,
                                                block_id=block['block_id'])
            acqEra = {}
            prsEra = {}
            if dataset["acquisition_era_name"] not in ( "", None):
                acqEra = self.aelist.execute(conn,
                        acquisitionEra=dataset["acquisition_era_name"])[0]
            if dataset["processing_version"] not in ("", None):
                prsEra = self.pelist.execute(conn,
                        processingV=dataset["processing_version"])[0]
            primds = self.primdslist.execute(conn,
                        primary_ds_name=dataset["primary_ds_name"])[0]
            del dataset["primary_ds_name"], dataset['primary_ds_type']
            files = self.filelist.execute(conn, block_name=block_name)
            for f in files:
                #There are a trade off between json sorting and db query.
                #We keep lumi sec in a file, but the file parentage seperate
                #from file
		file_lumi_list = []
                for item in self.fllist.execute(conn, logical_file_name=f['logical_file_name'], migration=True):
		    file_lumi_list.append(item)
		#print "---YG file lumi list---"	
		f.update(file_lumi_list = file_lumi_list)
		del file_lumi_list #YG 09/2015
                del f['branch_hash_id']
            del dataset["acquisition_era_name"], dataset["processing_version"]
            del block["dataset"]
            result = dict(block=block, dataset=dataset, primds=primds,
                          files=files, block_parent_list=bparent,
                          ds_parent_list=dsparent, file_conf_list=fconfig_list,
                          file_parent_list=fparent_list2, dataset_conf_list=dconfig_list)
            if acqEra:
                result["acquisition_era"] = acqEra
            if prsEra:
                result["processing_era"] = prsEra
            return result
        finally:
            if conn:
                conn.close()
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
698394
def parse_blocks(lines):  # type: (List[str]) -> List[List[str]]
    
    blocks = []

    while lines:
        if lines[0] == '':
            lines.pop(0)
        else:
            blocks.append(parse_block(lines))

    return blocks
610891
def _extend_blocks(result, blocks=None):
    
    from pandas.core.internals import BlockManager
    if blocks is None:
        blocks = []
    if isinstance(result, list):
        for r in result:
            if isinstance(r, list):
                blocks.extend(r)
            else:
                blocks.append(r)
    elif isinstance(result, BlockManager):
        blocks.extend(result.blocks)
    else:
        blocks.append(result)
    return blocks
207592
def _block(self, count):
        
        blocks, remainder = divmod(count, BLOCKSIZE)
        if remainder:
            blocks += 1
        return blocks * BLOCKSIZE