ak.contents.RegularArray#

Defined in awkward.contents.regulararray on line 53.

class ak.contents.RegularArray(self, content, size, zeros_length=0, *, parameters=None)#

RegularArray describes lists that all have the same length, the single integer size. Its underlying content is a flattened view of the data; that is, each list is not stored separately in memory, but is inferred as a subinterval of the underlying data.

If the content length is not an integer multiple of size, then the length of the RegularArray is truncated to the largest integer multiple.

An extra field zeros_length is ignored unless the size is zero. This sets the length of the RegularArray in only those cases, so that it is possible for an array to contain a non-zero number of zero-length lists with regular type.

A multidimensional ak.contents.NumpyArray is equivalent to a one-dimensional ak.layout.NumpyArray nested within several RegularArrays, one for each dimension. However, RegularArrays can be used to make lists of any other type.

Like ak.contents.ListArray and ak.contents.ListOffsetArray, a RegularArray can represent strings if its __array__ parameter is "string" (UTF-8 assumed) or "bytestring" (no encoding assumed) and it contains an ak.contents.NumpyArray of dtype=np.uint8 whose __array__ parameter is "char" (UTF-8 assumed) or "byte" (no encoding assumed).

RegularArray corresponds to an Apache Arrow FixedSizeList.

To illustrate how the constructor arguments are interpreted, the following is a simplified implementation of __init__, __len__, and __getitem__:

class RegularArray(Content):
    def __init__(self, content, size, zeros_length=0):
        assert isinstance(content, Content)
        assert isinstance(size, int)
        assert isinstance(zeros_length, int)
        assert size >= 0
        if size != 0:
            length = len(content) // size  # floor division
        else:
            assert zeros_length >= 0
            length = zeros_length
        self.content = content
        self.size = size
        self.length = length

    def __len__(self):
        return self.length

    def __getitem__(self, where):
        if isinstance(where, int):
            if where < 0:
                where += len(self)
            assert 0 <= where < len(self)
            return self.content[(where) * self.size : (where + 1) * self.size]

        elif isinstance(where, slice) and where.step is None:
            start = where.start * self.size
            stop = where.stop * self.size
            zeros_length = where.stop - where.start
            return RegularArray(
                self.content[start:stop], self.size, zeros_length
            )

        elif isinstance(where, str):
            return RegularArray(self.content[where], self.size, self.length)

        else:
            raise AssertionError(where)
ak.contents.RegularArray.size#
ak.contents.RegularArray.copy(self, content=UNSET, size=UNSET, zeros_length=UNSET, *, parameters=UNSET)#
ak.contents.RegularArray.__copy__(self)#
ak.contents.RegularArray.__deepcopy__(self, memo)#
ak.contents.RegularArray.simplified(cls, content, size, zeros_length=0, *, parameters=None)#
ak.contents.RegularArray.offsets#
ak.contents.RegularArray.starts#
ak.contents.RegularArray.stops#
ak.contents.RegularArray._form_with_key(self, getkey)#
ak.contents.RegularArray._to_buffers(self, form, getkey, container, backend, byteorder)#
ak.contents.RegularArray._to_typetracer(self, forget_length)#
ak.contents.RegularArray._touch_data(self, recursive)#
ak.contents.RegularArray._touch_shape(self, recursive)#
ak.contents.RegularArray.length#
ak.contents.RegularArray.__repr__(self)#
ak.contents.RegularArray._repr(self, indent, pre, post)#
ak.contents.RegularArray.to_ListOffsetArray64(self, start_at_zero=False)#
ak.contents.RegularArray.to_RegularArray(self)#
ak.contents.RegularArray.maybe_to_NumpyArray(self)#
ak.contents.RegularArray._getitem_nothing(self)#
ak.contents.RegularArray._is_getitem_at_placeholder(self)#
ak.contents.RegularArray._getitem_at(self, where)#
ak.contents.RegularArray._getitem_range(self, start, stop)#
ak.contents.RegularArray._getitem_field(self, where, only_fields=())#
ak.contents.RegularArray._getitem_fields(self, where, only_fields=())#
ak.contents.RegularArray._carry(self, carry, allow_lazy)#
ak.contents.RegularArray._compact_offsets64(self, start_at_zero)#
ak.contents.RegularArray._broadcast_tooffsets64(self, offsets)#
ak.contents.RegularArray._getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail)#
ak.contents.RegularArray._getitem_next(self, head, tail, advanced)#
ak.contents.RegularArray._offsets_and_flattened(self, axis, depth)#
ak.contents.RegularArray._mergeable_next(self, other, mergebool)#
ak.contents.RegularArray._mergemany(self, others)#
ak.contents.RegularArray._fill_none(self, value)#
ak.contents.RegularArray._local_index(self, axis, depth)#
ak.contents.RegularArray._numbers_to_type(self, name, including_unknown)#
ak.contents.RegularArray._is_unique(self, negaxis, starts, parents, outlength)#
ak.contents.RegularArray._unique(self, negaxis, starts, parents, outlength)#
ak.contents.RegularArray._argsort_next(self, negaxis, starts, shifts, parents, outlength, ascending, stable)#
ak.contents.RegularArray._sort_next(self, negaxis, starts, parents, outlength, ascending, stable)#
ak.contents.RegularArray._combinations(self, n, replacement, recordlookup, parameters, axis, depth)#
ak.contents.RegularArray._reduce_next(self, reducer, negaxis, starts, shifts, parents, outlength, mask, keepdims, behavior)#
ak.contents.RegularArray._validity_error(self, path)#
ak.contents.RegularArray._nbytes_part(self)#
ak.contents.RegularArray._pad_none(self, target, axis, depth, clip)#
ak.contents.RegularArray._to_backend_array(self, allow_missing, backend)#
ak.contents.RegularArray._to_arrow(self, pyarrow, mask_node, validbytes, length, options)#
ak.contents.RegularArray._remove_structure(self, backend, options)#
ak.contents.RegularArray._drop_none(self)#
ak.contents.RegularArray._recursively_apply(self, action, depth, depth_context, lateral_context, options)#
ak.contents.RegularArray.to_packed(self, recursive=True)#
ak.contents.RegularArray._to_list(self, behavior, json_conversions)#
ak.contents.RegularArray._to_backend(self, backend)#
ak.contents.RegularArray._is_equal_to(self, other, index_dtype, numpyarray, all_parameters)#