Create a slice of memory for turtle data storage
544204
def create_turtle(self, id, shape, model_init, color_init):
        """"""
        assert id not in self.id_to_shape
        data = self._create_turtle(id, shape, model_init, color_init)
        self.id_to_shape[id] = shape
        return data
587350
def append(self, data, size):
        
        return lib.zchunk_append(self._as_parameter_, data, size)
708593
def extern_store_tuple(self, context_handle, vals_ptr, vals_len):
    """"""
    c = self._ffi.from_handle(context_handle)
    return c.to_value(tuple(c.from_value(val[0]) for val in self._ffi.unpack(vals_ptr, vals_len)))
402410
def set_data(self, data, addr=0):
        '''
        
        '''
        if self._mem_bytes < len(data):
            raise ValueError('Size of data (%d bytes) is too big for memory (%d bytes)' % (len(data), self._mem_bytes))
        self._intf.write(self._conf['base_addr'] + self._spi_mem_offset + addr, data)
1308899
def load_data(subseqs):
        """"""
        print('            . load_data')
        lines = Lines()
        lines.add(1, 'cpdef inline void load_data(self, int idx) %s:' % _nogil)
        lines.add(2, 'cdef int jdx0, jdx1, jdx2, jdx3, jdx4, jdx5')
        for seq in subseqs:
            lines.add(2, 'if self._%s_diskflag:' % seq.name)
            if seq.NDIM == 0:
                lines.add(3, 'fread(&self.%s, 8, 1, self._%s_file)'
                             % (2*(seq.name,)))
            else:
                lines.add(3, 'fread(&self.%s[0], 8, self._%s_length, '
                             'self._%s_file)' % (3*(seq.name,)))
            lines.add(2, 'elif self._%s_ramflag:' % seq.name)
            if seq.NDIM == 0:
                lines.add(3, 'self.%s = self._%s_array[idx]' % (2*(seq.name,)))
            else:
                indexing = ''
                for idx in range(seq.NDIM):
                    lines.add(3+idx, 'for jdx%d in range(self._%s_length_%d):'
                                     % (idx, seq.name, idx))
                    indexing += 'jdx%d,' % idx
                indexing = indexing[:-1]
                lines.add(3+seq.NDIM, 'self.%s[%s] = self._%s_array[idx,%s]'
                                      % (2*(seq.name, indexing)))
        return lines
1175612
def slice_by_size(seq, size):
    """"""
    filling = null
    for it in zip(*(itertools_chain(seq, [filling] * size),) * size):
        if filling in it:
            it = tuple(i for i in it if i is not filling)
        if it:
            yield it
285154
def memmap_array(self, dtype, shape, offset=0, mode='r', order='C'):
        """"""
        if not self.is_file:
            raise ValueError('Cannot memory-map file without fileno')
        return numpy.memmap(self._fh, dtype=dtype, mode=mode,
                            offset=self._offset + offset,
                            shape=shape, order=order)
1078548
def chunks(data, size):
    
    for i in range(0, len(data), size):
        yield data[i:i + size]
1095445
def to_ubyte_array(barray):
    """"""
    bs = (ctypes.c_ubyte * len(barray))()
    pack_into('%ds' % len(barray), bs, 0, barray)

    return bs
1262763
function slice(vtrees, counter, length) {
  return vtrees.slice(counter.count, counter.count += length);
}
1015754
def generate_chunks(data, chunk_size=DEFAULT_CHUNK_SIZE):
    """"""
    iterator = iter(repeated.getvalues(data))

    while True:
        chunk = list(itertools.islice(iterator, chunk_size))
        if not chunk:
            return

        yield chunk
125860
public static void createSegmentMemory(LeftTupleSource tupleSource, InternalWorkingMemory wm) {
        Memory mem = wm.getNodeMemory((MemoryFactory) tupleSource);
        SegmentMemory smem = mem.getSegmentMemory();
        if ( smem == null ) {
            createSegmentMemory(tupleSource, mem, wm);
        }
    }
1211085
def copy(data, start=0, stop=None, blen=None, storage=None, create='array',
         **kwargs):
    """"""

    # setup
    storage = _util.get_storage(storage)
    blen = _util.get_blen_array(data, blen)
    if stop is None:
        stop = len(data)
    else:
        stop = min(stop, len(data))
    length = stop - start
    if length < 0:
        raise ValueError('invalid stop/start')

    # copy block-wise
    out = None
    for i in range(start, stop, blen):
        j = min(i+blen, stop)
        block = data[i:j]
        if out is None:
            out = getattr(storage, create)(block, expectedlen=length, **kwargs)
        else:
            out.append(block)

    return out
597384
def createMemoryParserCtxt(buffer, size):
    
    ret = libxml2mod.xmlCreateMemoryParserCtxt(buffer, size)
    if ret is None:raise parserError('xmlCreateMemoryParserCtxt() failed')
    return parserCtxt(_obj=ret)
973341
def chunk_data(payload, max_size)
      total = payload.bytesize
      cursor = 0
      while (total - cursor) > max_size
        yield payload.byteslice(cursor, max_size)
        cursor += max_size
      end
      payload.byteslice(cursor, total - cursor)
    end
916735
def _slice_bounded(self, tuple_key, data_slice):
        
        slices = [el for el in tuple_key if isinstance(el, slice)]
        if any(el.step for el in slices):
            raise Exception("DynamicMap slices cannot have a step argument")
        elif len(slices) not in [0, len(tuple_key)]:
            raise Exception("Slices must be used exclusively or not at all")
        elif not slices:
            return None

        sliced = self.clone(self)
        for i, slc in enumerate(tuple_key):
            (start, stop) = slc.start, slc.stop
            if start is not None and start < sliced.kdims[i].range[0]:
                raise Exception("Requested slice below defined dimension range.")
            if stop is not None and stop > sliced.kdims[i].range[1]:
                raise Exception("Requested slice above defined dimension range.")
            sliced.kdims[i].soft_range = (start, stop)
        if data_slice:
            if not isinstance(sliced, DynamicMap):
                return self._dataslice(sliced, data_slice)
            else:
                from ..util import Dynamic
                if len(self):
                    slices = [slice(None) for _ in range(self.ndims)] + list(data_slice)
                    sliced = super(DynamicMap, sliced).__getitem__(tuple(slices))
                dmap = Dynamic(self, operation=lambda obj, **dynkwargs: obj[data_slice],
                               streams=self.streams)
                dmap.data = sliced.data
                return dmap
        return sliced
480270
private Memory createNodeMemory( MemoryFactory node,
                                     InternalWorkingMemory wm ) {
        try {
            this.lock.lock();
            // need to try again in a synchronized code block to make sure
            // it was not created yet
            Memory memory = this.memories.get( node.getMemoryId() );
            if( memory == null ) {
                memory = node.createMemory( this.kBase.getConfiguration(), wm );

                if( !this.memories.compareAndSet( node.getMemoryId(), null, memory ) ) {
                    memory = this.memories.get( node.getMemoryId() );
                }

            }
            return memory;
        } finally {
            this.lock.unlock();

        }
    }