Get the highest block height in the atlas db
182138
def atlasdb_get_lastblock( con=None, path=None ):
    
    row = None
    with AtlasDBOpen(con=con, path=path) as dbcon:

        sql = "SELECT MAX(block_height) FROM zonefiles;"
        args = ()

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )

        row = {}
        for r in res:
            row.update(r)
            break

    return row['MAX(block_height)']
1286884
function BlockMapRecord(height) {
  if (!(this instanceof BlockMapRecord))
    return new BlockMapRecord(height);

  this.height = height != null ? height : -1;
  this.txs = new Map();
}
1075202
public static double findMaxCol(final int blockLength , final DSubmatrixD1 Y , final int col )
    {
        final int width = Math.min(blockLength,Y.col1-Y.col0);

        final double dataY[] = Y.original.data;

        double max = 0;

        for( int i = Y.row0; i < Y.row1; i += blockLength ) {
            int height = Math.min( blockLength , Y.row1 - i );

            int index = i*Y.original.numCols + height*Y.col0 + col;

            if( i == Y.row0 ) {
                index += width*col;
                for( int k = col; k < height; k++ , index += width ) {
                    double v = Math.abs(dataY[index]);
                    if( v > max ) {
                        max = v;
                    }
                }
            } else {
                for( int k = 0; k < height; k++ , index += width ) {
                    double v = Math.abs(dataY[index]);
                    if( v > max ) {
                        max = v;
                    }
                }
            }
        }

        return max;
    }
16931
def db_chainstate_get_block(cls, cur, block_height):
        
        query = 'SELECT * FROM chainstate WHERE block_id = ? ORDER BY vtxindex;'
        args = (block_height,)

        rows = cls.db_query_execute(cur, query, args, verbose=False)
        ret = []

        for r in rows:
            rowdata = {
                'txid': str(r['txid']),
                'block_id': r['block_id'],
                'txindex': r['txindex'],
                'vtxindex': r['vtxindex'],
                'opcode': str(r['opcode']),
                'data_hex': str(r['data_hex']),
                'senders': simplejson.loads(r['senders']),
                'tx_hex': str(r['tx_hex']),
                'tx_merkle_path': str(r['tx_merkle_path']),
                'fee': r['fee']
            }

            ret.append(rowdata)

        return ret
192576
def atlasdb_num_peers( con=None, path=None ):
    
    with AtlasDBOpen(con=con, path=path) as dbcon:

        sql = "SELECT MAX(peer_index) FROM peers;"
        args = ()

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )

        ret = []
        for row in res:
            tmp = {}
            tmp.update(row)
            ret.append(tmp)

        assert len(ret) == 1

    return ret[0]['MAX(peer_index)']
768971
def get_epoch_number( block_height ):
    
    global EPOCHS

    if block_height <= EPOCHS[0]['end_block']:
        return 0

    for i in xrange(1, len(EPOCHS)):
        if EPOCHS[i-1]['end_block'] < block_height and (block_height <= EPOCHS[i]['end_block'] or EPOCHS[i]['end_block'] == EPOCH_NOW):
            return i

    # should never happen 
    log.error("FATAL: No epoch for %s" % block_height)
    os.abort()
1145490
def _get_block(self):
    """"""
    b = self._fh.read(4) # get block size bytes
    #print self._fh.tell()
    if not b: raise StopIteration
    block_size = struct.unpack('<i',b)[0]
    return self._fh.read(block_size)
11461
private static long getBlockSize(LocatedBlocks lbs) throws IOException {
    List<LocatedBlock> locatedBlocks = lbs.getLocatedBlocks();
    long bs = -1;
    for (LocatedBlock lb: locatedBlocks) {
      if (lb.getBlockSize() > bs) {
        bs = lb.getBlockSize();
      }
    }
    return bs;
  }
408712
def _classic_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(_classic_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):
        full_block[:, :, :, index] = data_blocks[index]

    return full_block
115336
def _highlighBlocks(self, fromBlock, atLeastUntilBlock, timeout):
        endTime = time.time() + timeout

        block = fromBlock
        lineData = self._lineData(block.previous())

        while block.isValid() and block != atLeastUntilBlock:
            if time.time() >= endTime:  # time is over, schedule parsing later and release event loop
                self._pendingBlockNumber = block.blockNumber()
                self._pendingAtLeastUntilBlockNumber = atLeastUntilBlock.blockNumber()
                self._globalTimer.scheduleCallback(self._onContinueHighlighting)
                return

            contextStack = lineData[0] if lineData is not None else None
            if block.length() < 4096:
                lineData, highlightedSegments = self._syntax.highlightBlock(block.text(), contextStack)
            else:
                """Parser freezes for a long time, if line is too long
                invalid parsing results are still better, than freeze
                """
                lineData, highlightedSegments = None, []
            if lineData is not None:
                block.setUserData(_TextBlockUserData(lineData))
            else:
                block.setUserData(None)

            self._applyHighlightedSegments(block, highlightedSegments)
            block = block.next()

        # reached atLeastUntilBlock, now parse next only while data changed
        prevLineData = self._lineData(block)
        while block.isValid():
            if time.time() >= endTime:  # time is over, schedule parsing later and release event loop
                self._pendingBlockNumber = block.blockNumber()
                self._pendingAtLeastUntilBlockNumber = atLeastUntilBlock.blockNumber()
                self._globalTimer.scheduleCallback(self._onContinueHighlighting)
                return
            contextStack = lineData[0] if lineData is not None else None
            lineData, highlightedSegments = self._syntax.highlightBlock(block.text(), contextStack)
            if lineData is not None:
                block.setUserData(_TextBlockUserData(lineData))
            else:
                block.setUserData(None)

            self._applyHighlightedSegments(block, highlightedSegments)
            if prevLineData == lineData:
                break

            block = block.next()
            prevLineData = self._lineData(block)

        # sucessfully finished, reset pending tasks
        self._pendingBlockNumber = None
        self._pendingAtLeastUntilBlockNumber = None

        
        documentLayout = self._textEdit.document().documentLayout()
        documentLayout.documentSizeChanged.emit(documentLayout.documentSize())
170713
def upper(self) -> Set[Point2]:
        
        max_height = max([self.height_at(p) for p in self._points])
        return {p for p in self._points if self.height_at(p) == max_height}
471694
def max(self):
        
        res = self._qexec("max(%s)" % self._name)
        if len(res) > 0:
            self._max = res[0][0]
        return self._max
859572
def max(self):
        
        return self._constructor(self.values.max(axis=self.baseaxes, keepdims=True))
1217226
def get_block_hash(block_height, coin_symbol='btc', api_key=None):
    '''
    
    '''
    return get_block_overview(block_representation=block_height,
            coin_symbol=coin_symbol, txn_limit=1, api_key=api_key)['hash']
825524
def get_block(self, block_id):
        

        block = backend.query.get_block(self.connection, block_id)
        latest_block = self.get_latest_block()
        latest_block_height = latest_block['height'] if latest_block else 0

        if not block and block_id > latest_block_height:
            return

        result = {'height': block_id,
                  'transactions': []}

        if block:
            transactions = backend.query.get_transactions(self.connection, block['transactions'])
            result['transactions'] = [t.to_dict() for t in Transaction.from_db(self, transactions)]

        return result
869954
function getBestBinFit( start, len, blocks ) {
	var b, s, e, end = start + len, found = false,
		c, last_c = 0, last_s = 0, last_i = -1, last_bin = null;

	// Find the biggest chunk that can fit on these data
	for (var bi=0, bl=blocks.length; bi<bl; ++bi) {
		b = blocks[bi]; found = false;
		for (var i=0, il=b.length; i<il; ++i) {
			s = b[i][0]; e = s + b[i][1];

			// Find the common region of block-scan frame
			if ( ((s >= start) && (s < end-1)) ||	// Start in bounds
				 ((e >= start) && (e < end-1)) ||	// End in bounds
				 ((s <= start) && (e >= end)) )		// 
			{

				// Check bounds
				if (s < start) s = start;
				if (s > end-2) continue;
				if (e > end) e = end;
				if (s === e) continue;

				// Test coverage
				c = e - s;
				if (c > last_c) {
					last_c = c;
					last_s = s;
					last_bin = b[i];
					found = true;
				}

			}

		}

		// Prefer priority to length across different blocks
		// on the first block (repeated)
		if ((bi === 0) && found)
			return last_bin;

	}

	// Update bounds
	if (last_bin) {
		last_bin = last_bin.slice();
		last_bin[0] = last_s;
		last_bin[1] = last_c;
	}

	// Return last bin
	return last_bin;
}
1282859
def _mosaic_get_full_block(sorted_mosaics):
    
    # For each slice / mosaic create a data volume block
    data_blocks = []
    for index in range(0, len(sorted_mosaics)):
        data_blocks.append(_mosaic_to_block(sorted_mosaics[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):
        full_block[:, :, :, index] = data_blocks[index]

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

    return full_block