ak.contents.RegularArray ------------------------ .. py:module: ak.contents.RegularArray Defined in `awkward.contents.regulararray `__ on `line 53 `__. .. py: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 :py:obj:`ak.contents.NumpyArray` is equivalent to a one-dimensional :py:obj:`ak.layout.NumpyArray` nested within several RegularArrays, one for each dimension. However, RegularArrays can be used to make lists of any other type. Like :py:obj:`ak.contents.ListArray` and :py:obj:`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 :py:obj:`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__``: .. code-block:: python 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: .. py:attribute:: ak.contents.RegularArray.size .. _ak-contents-regulararray-copy: .. py:method:: ak.contents.RegularArray.copy(self, content=UNSET, size=UNSET, zeros_length=UNSET, *, parameters=UNSET) .. _ak-contents-regulararray-__copy__: .. py:method:: ak.contents.RegularArray.__copy__(self) .. _ak-contents-regulararray-__deepcopy__: .. py:method:: ak.contents.RegularArray.__deepcopy__(self, memo) .. _ak-contents-regulararray-simplified: .. py:method:: ak.contents.RegularArray.simplified(cls, content, size, zeros_length=0, *, parameters=None) .. _ak-contents-regulararray-offsets: .. py:attribute:: ak.contents.RegularArray.offsets .. _ak-contents-regulararray-starts: .. py:attribute:: ak.contents.RegularArray.starts .. _ak-contents-regulararray-stops: .. py:attribute:: ak.contents.RegularArray.stops .. _ak-contents-regulararray-_form_with_key: .. py:method:: ak.contents.RegularArray._form_with_key(self, getkey) .. _ak-contents-regulararray-_form_with_key_path: .. py:method:: ak.contents.RegularArray._form_with_key_path(self, path) .. _ak-contents-regulararray-_to_buffers: .. py:method:: ak.contents.RegularArray._to_buffers(self, form, getkey, container, backend, byteorder) .. _ak-contents-regulararray-_to_typetracer: .. py:method:: ak.contents.RegularArray._to_typetracer(self, forget_length) .. _ak-contents-regulararray-_touch_data: .. py:method:: ak.contents.RegularArray._touch_data(self, recursive) .. _ak-contents-regulararray-_touch_shape: .. py:method:: ak.contents.RegularArray._touch_shape(self, recursive) .. _ak-contents-regulararray-length: .. py:attribute:: ak.contents.RegularArray.length .. _ak-contents-regulararray-__repr__: .. py:method:: ak.contents.RegularArray.__repr__(self) .. _ak-contents-regulararray-_repr: .. py:method:: ak.contents.RegularArray._repr(self, indent, pre, post) .. _ak-contents-regulararray-to_listoffsetarray64: .. py:method:: ak.contents.RegularArray.to_ListOffsetArray64(self, start_at_zero=False) .. _ak-contents-regulararray-to_regulararray: .. py:method:: ak.contents.RegularArray.to_RegularArray(self) .. _ak-contents-regulararray-maybe_to_numpyarray: .. py:method:: ak.contents.RegularArray.maybe_to_NumpyArray(self) .. _ak-contents-regulararray-_getitem_nothing: .. py:method:: ak.contents.RegularArray._getitem_nothing(self) .. _ak-contents-regulararray-_is_getitem_at_placeholder: .. py:method:: ak.contents.RegularArray._is_getitem_at_placeholder(self) .. _ak-contents-regulararray-_getitem_at: .. py:method:: ak.contents.RegularArray._getitem_at(self, where) .. _ak-contents-regulararray-_getitem_range: .. py:method:: ak.contents.RegularArray._getitem_range(self, start, stop) .. _ak-contents-regulararray-_getitem_field: .. py:method:: ak.contents.RegularArray._getitem_field(self, where, only_fields=()) .. _ak-contents-regulararray-_getitem_fields: .. py:method:: ak.contents.RegularArray._getitem_fields(self, where, only_fields=()) .. _ak-contents-regulararray-_carry: .. py:method:: ak.contents.RegularArray._carry(self, carry, allow_lazy) .. _ak-contents-regulararray-_compact_offsets64: .. py:method:: ak.contents.RegularArray._compact_offsets64(self, start_at_zero) .. _ak-contents-regulararray-_broadcast_tooffsets64: .. py:method:: ak.contents.RegularArray._broadcast_tooffsets64(self, offsets) .. _ak-contents-regulararray-_getitem_next_jagged: .. py:method:: ak.contents.RegularArray._getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail) .. _ak-contents-regulararray-_getitem_next: .. py:method:: ak.contents.RegularArray._getitem_next(self, head, tail, advanced) .. _ak-contents-regulararray-_offsets_and_flattened: .. py:method:: ak.contents.RegularArray._offsets_and_flattened(self, axis, depth) .. _ak-contents-regulararray-_mergeable_next: .. py:method:: ak.contents.RegularArray._mergeable_next(self, other, mergebool) .. _ak-contents-regulararray-_mergemany: .. py:method:: ak.contents.RegularArray._mergemany(self, others) .. _ak-contents-regulararray-_fill_none: .. py:method:: ak.contents.RegularArray._fill_none(self, value) .. _ak-contents-regulararray-_local_index: .. py:method:: ak.contents.RegularArray._local_index(self, axis, depth) .. _ak-contents-regulararray-_numbers_to_type: .. py:method:: ak.contents.RegularArray._numbers_to_type(self, name, including_unknown) .. _ak-contents-regulararray-_is_unique: .. py:method:: ak.contents.RegularArray._is_unique(self, negaxis, starts, parents, outlength) .. _ak-contents-regulararray-_unique: .. py:method:: ak.contents.RegularArray._unique(self, negaxis, starts, parents, outlength) .. _ak-contents-regulararray-_argsort_next: .. py:method:: ak.contents.RegularArray._argsort_next(self, negaxis, starts, shifts, parents, outlength, ascending, stable) .. _ak-contents-regulararray-_sort_next: .. py:method:: ak.contents.RegularArray._sort_next(self, negaxis, starts, parents, outlength, ascending, stable) .. _ak-contents-regulararray-_combinations: .. py:method:: ak.contents.RegularArray._combinations(self, n, replacement, recordlookup, parameters, axis, depth) .. _ak-contents-regulararray-_reduce_next: .. py:method:: ak.contents.RegularArray._reduce_next(self, reducer, negaxis, starts, shifts, parents, outlength, mask, keepdims, behavior) .. _ak-contents-regulararray-_validity_error: .. py:method:: ak.contents.RegularArray._validity_error(self, path) .. _ak-contents-regulararray-_nbytes_part: .. py:method:: ak.contents.RegularArray._nbytes_part(self) .. _ak-contents-regulararray-_pad_none: .. py:method:: ak.contents.RegularArray._pad_none(self, target, axis, depth, clip) .. _ak-contents-regulararray-_to_backend_array: .. py:method:: ak.contents.RegularArray._to_backend_array(self, allow_missing, backend) .. _ak-contents-regulararray-_to_arrow: .. py:method:: ak.contents.RegularArray._to_arrow(self, pyarrow, mask_node, validbytes, length, options) .. _ak-contents-regulararray-_remove_structure: .. py:method:: ak.contents.RegularArray._remove_structure(self, backend, options) .. _ak-contents-regulararray-_drop_none: .. py:method:: ak.contents.RegularArray._drop_none(self) .. _ak-contents-regulararray-_recursively_apply: .. py:method:: ak.contents.RegularArray._recursively_apply(self, action, depth, depth_context, lateral_context, options) .. _ak-contents-regulararray-to_packed: .. py:method:: ak.contents.RegularArray.to_packed(self, recursive=True) .. _ak-contents-regulararray-_to_list: .. py:method:: ak.contents.RegularArray._to_list(self, behavior, json_conversions) .. _ak-contents-regulararray-_to_backend: .. py:method:: ak.contents.RegularArray._to_backend(self, backend) .. _ak-contents-regulararray-_is_equal_to: .. py:method:: ak.contents.RegularArray._is_equal_to(self, other, index_dtype, numpyarray, all_parameters)