ak.contents.ByteMaskedArray#

Defined in awkward.contents.bytemaskedarray on line 56.

class ak.contents.ByteMaskedArray(self, mask, content, valid_when, *, parameters=None)#

The ByteMaskedArray implements an ak.types.OptionType with two aligned buffers, a boolean mask and content. At any element i where mask[i] == valid_when, the value can be found at content[i]. If mask[i] != valid_when, the value is missing (None).

This is equivalent to NumPy’s masked arrays if valid_when=False.

There is no Apache Arrow equivalent because Arrow uses bitmaps to mask all node types.

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

class ByteMaskedArray(Content):
    def __init__(self, mask, content, valid_when):
        assert isinstance(mask, Index8)
        assert isinstance(content, Content)
        assert isinstance(valid_when, bool)
        assert len(mask) <= len(content)
        self.mask = mask
        self.content = content
        self.valid_when = valid_when

    def __len__(self):
        return len(self.mask)

    def __getitem__(self, where):
        if isinstance(where, int):
            if where < 0:
                where += len(self)
            assert 0 <= where < len(self)
            if self.mask[where] == self.valid_when:
                return self.content[where]
            else:
                return None

        elif isinstance(where, slice) and where.step is None:
            return ByteMaskedArray(
                self.mask[where.start : where.stop],
                self.content[where.start : where.stop],
                valid_when=self.valid_when,
            )

        elif isinstance(where, str):
            return ByteMaskedArray(
                self.mask, self.content[where], valid_when=self.valid_when
            )

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