uproot.source.chunk.Chunk

Defined in uproot.source.chunk on line 251.

class uproot.source.chunk.Chunk(source: Source, start: int, stop: int, future, is_memmap: bool = False)
Parameters:

A range of bytes from a uproot.source.chunk.Source, which may be synchronously or asynchronously filled.

The following methods must wait for the future to complete (to be filled):

wrap

classmethod Chunk.wrap(source: Source, data: numpy.ndarray | bytes, start: int = 0)
Parameters:
  • source (uproot.source.chunk.Source) – Source to attach to the new chunk.

  • data (numpy.ndarray of numpy.uint8) – Data for the new chunk.

  • start (int) – Virtual starting position for this chunk; if X, then a uproot.Cursor is valid from X to X + len(data).

Manually creates a synchronous uproot.source.chunk.Chunk.

source

Chunk.source

Source from which this Chunk is derived.

start

Chunk.start

Seek position of the first byte to include.

stop

Chunk.stop

Seek position of the first byte to exclude (one greater than the last byte to include).

future

Chunk.future

Handle to the synchronous or asynchronous data. A chunk is “filled” when the future completes.

is_memmap

Chunk.is_memmap

If True, the raw_data is or will be a view into a memmap file, which must be handled carefully. Accessing that data after the file is closed causes a segfault.

detach_memmap

Chunk.detach_memmap()

Returns a Chunk (possibly this one) that is not tied to live memmap data. Such a Chunk can be accessed after the file is closed without segfaults.

wait

Chunk.wait(insist: bool = True)
Parameters:

insist (bool or int) – If True, raise an OSError if raw_data does does not have exactly stop - start bytes. If False, do not check. If an integer, only raise an OSError if data up to that index can’t be supplied (i.e. require len(raw_data) >= insist - start).

Explicitly wait until the chunk is filled (the future completes).

raw_data

Chunk.raw_data

Data from the Source as a numpy.ndarray of numpy.uint8.

This method will wait until the chunk is filled (the future completes), if it isn’t already.

get

Chunk.get(start: int, stop: int, cursor: Cursor, context: dict) ndarray
Parameters:
  • start (int) – Seek position of the first byte to include.

  • stop (int) – Seek position of the first byte to exclude (one greater than the last byte to include).

  • cursor (uproot.Cursor) – A pointer to the current position in this chunk.

  • context (dict) – Auxiliary data used in deserialization.

Returns a subinterval of the raw_data as a numpy.ndarray of numpy.uint8.

Note that this start and stop are in the same coordinate system as the start and stop. That is, to get the whole chunk, use start=chunk.start and stop=chunk.stop.

This method will wait until the chunk is filled (the future completes), if it isn’t already.

remainder

Chunk.remainder(start: int, cursor: Cursor, context: dict) ndarray
Parameters:
  • start (int) – Seek position of the first byte to include.

  • cursor (uproot.Cursor) – A pointer to the current position in this chunk.

  • context (dict) – Auxiliary data used in deserialization.

Returns a subinterval of the raw_data as a numpy.ndarray of numpy.uint8 from start to the end of the chunk.

Note that this start is in the same coordinate system as the start. That is, to get the whole chunk, use start=chunk.start.

This method will wait until the chunk is filled (the future completes), if it isn’t already.