3#ifndef AWKWARD_SLICE_H_
4#define AWKWARD_SLICE_H_
34 virtual const std::string
158 const int64_t start_;
224 template <
typename T>
226#ifdef AWKWARD_SLICE_NO_EXTERN_TEMPLATE
250 const std::vector<int64_t>& shape,
251 const std::vector<int64_t>& strides,
bool frombool);
266 const std::vector<int64_t>
275 const std::vector<int64_t>
323 const std::vector<int64_t> shape_;
325 const std::vector<int64_t> strides_;
330#ifndef AWKWARD_SLICE_NO_EXTERN_TEMPLATE
377 const std::string key_;
401 const std::vector<std::string>
421 const std::vector<std::string> keys_;
430 template <
typename T>
432#ifdef AWKWARD_SLICE_NO_EXTERN_TEMPLATE
446 const Index8& originalmask,
492 const Index8 originalmask_;
497#ifndef AWKWARD_SLICE_NO_EXTERN_TEMPLATE
510 template <
typename T>
512#ifdef AWKWARD_SLICE_NO_EXTERN_TEMPLATE
575#ifndef AWKWARD_SLICE_NO_EXTERN_TEMPLATE
597 Slice(
const std::vector<SliceItemPtr>& items,
bool sealed);
602 Slice(
const std::vector<SliceItemPtr>& items);
608 const std::vector<SliceItemPtr>
714 std::vector<SliceItemPtr> items_;
A contiguous, one-dimensional array of integers used to represent data structures,...
Definition: Index.h:82
Represents an array of integers in a slice (possibly converted from an array of booleans).
Definition: Slice.h:229
const std::string tostring() const override
Returns a string representation of this slice item (single-line custom format).
const IndexOf< T > index() const
A flattened version of the array used for slicing.
const int64_t length() const
The length of the logical array: shape[0].
bool frombool() const
If true, this integer array of positions was derived from a boolean array mask (from NumPy's nonzero ...
const std::vector< int64_t > strides() const
Length of each dimension in number of items. The length of strides must match the length of shape.
const SliceItemPtr shallow_copy() const override
Copies this node without copying any associated arrays.
int64_t ndim() const
The number of dimensions: shape.size().
virtual bool referentially_equal(const SliceItemPtr &other) const override
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
const std::vector< int64_t > shape() const
Number of elements in each dimension, like NumPy's array shape.
const IndexOf< T > ravel() const
Returns a one-dimensional contiguous version of the array, like NumPy's ravel.
const std::string tostring_part() const
bool preserves_type(const Index64 &advanced) const override
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
Represents an integer in a tuple of slices passed to __getitem__ in Python.
Definition: Slice.h:58
const std::string tostring() const override
Returns a string representation of this slice item (single-line custom format).
SliceAt(int64_t at)
Creates a SliceAt from a full set of parameters.
int64_t at() const
The integer that this slice item represents.
const SliceItemPtr shallow_copy() const override
Copies this node without copying any associated arrays.
virtual bool referentially_equal(const SliceItemPtr &other) const override
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
bool preserves_type(const Index64 &advanced) const override
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
Represents a Python Ellipsis object (usual syntax: array[...]).
Definition: Slice.h:169
const std::string tostring() const override
Returns a string representation of this slice item (single-line custom format).
SliceEllipsis()
Creates a SliceEllipsis.
const SliceItemPtr shallow_copy() const override
Copies this node without copying any associated arrays.
virtual bool referentially_equal(const SliceItemPtr &other) const override
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
bool preserves_type(const Index64 &advanced) const override
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
Represents a single string in a slice tuple, indicating that a RecordArray should be replaced by one ...
Definition: Slice.h:340
const std::string tostring() const override
Returns a string representation of this slice item (single-line custom format).
SliceField(const std::string &key)
Creates a SliceField from a full set of parameters.
const SliceItemPtr shallow_copy() const override
Copies this node without copying any associated arrays.
const std::string key() const
The name of the field to select.
virtual bool referentially_equal(const SliceItemPtr &other) const override
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
bool preserves_type(const Index64 &advanced) const override
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
const std::string tostring() const override
Returns a string representation of this slice item (single-line custom format).
SliceFields(const std::vector< std::string > &keys)
Creates a SliceFields from a full set of parameters.
const std::vector< std::string > keys() const
The names of the fields to select.
const SliceItemPtr shallow_copy() const override
Copies this node without copying any associated arrays.
virtual bool referentially_equal(const SliceItemPtr &other) const override
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
bool preserves_type(const Index64 &advanced) const override
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
Abstract class for slice items, which are elements of a tuple passed to an array's __getitem__ in Pyt...
Definition: Slice.h:21
virtual const SliceItemPtr shallow_copy() const =0
Copies this node without copying any associated arrays.
virtual const std::string tostring() const =0
Returns a string representation of this slice item (single-line custom format).
virtual bool referentially_equal(const SliceItemPtr &other) const =0
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
virtual bool preserves_type(const Index64 &advanced) const =0
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
virtual ~SliceItem()
Virtual destructor acts as a first non-inline virtual function that determines a specific translation...
Represents an array of nested lists, where the content may be SliceArrayOf, SliceMissingOf,...
Definition: Slice.h:515
const std::string tostring() const override
Returns a string representation of this slice item (single-line custom format).
SliceJaggedOf(const IndexOf< T > &offsets, const SliceItemPtr &content)
Creates a SliceJaggedOf with a full set of parameters.
const SliceItemPtr shallow_copy() const override
Copies this node without copying any associated arrays.
virtual bool referentially_equal(const SliceItemPtr &other) const override
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
const IndexOf< T > offsets() const
Positions where one nested list stops and the next starts in the content in the same sense as ListOff...
int64_t length() const
The length of the array: len(offsets) - 1.
const SliceItemPtr content() const
The contiguous content of the nested lists, like ListOffsetArray's content.
const std::string tostring_part() const
bool preserves_type(const Index64 &advanced) const override
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
Represents a SliceArrayOf, SliceMissingOf, or SliceJaggedOf with missing values: None (no equivalent ...
Definition: Slice.h:435
const std::string tostring() const override
Returns a string representation of this slice item (single-line custom format).
const IndexOf< T > index() const
Positions in the content or negative values representing None in the same sense as IndexedOptionArray...
SliceMissingOf(const IndexOf< T > &index, const Index8 &originalmask, const SliceItemPtr &content)
Creates a SliceMissingOf with a full set of parameters.
const SliceItemPtr shallow_copy() const override
Copies this node without copying any associated arrays.
virtual bool referentially_equal(const SliceItemPtr &other) const override
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
const Index8 originalmask() const
The array of booleans from which the index was derived.
int64_t length() const
The length of the array: len(index).
const SliceItemPtr content() const
The non-None values of the array, much like an IndexedOptionArray's content.
const std::string tostring_part() const
bool preserves_type(const Index64 &advanced) const override
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
Represents NumPy's newaxis marker (a.k.a. None), which prompts __getitem__ to insert a length-1 regul...
Definition: Slice.h:197
const std::string tostring() const override
Returns a string representation of this slice item (single-line custom format).
SliceNewAxis()
Creates a SliceNewAxis.
const SliceItemPtr shallow_copy() const override
Copies this node without copying any associated arrays.
virtual bool referentially_equal(const SliceItemPtr &other) const override
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
bool preserves_type(const Index64 &advanced) const override
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
Represents a Python slice object (usual syntax: array[start:stop:step]).
Definition: Slice.h:93
const std::string tostring() const override
Returns a string representation of this slice item (single-line custom format).
SliceRange(int64_t start, int64_t stop, int64_t step)
Creates a SliceRange from a full set of parameters.
int64_t stop() const
The exclusive stopping position.
int64_t start() const
The inclusive starting position.
const SliceItemPtr shallow_copy() const override
Copies this node without copying any associated arrays.
bool hasstart() const
Returns true if start is not Slice::none; false otherwise.
bool hasstop() const
Returns true if stop is not Slice::none; false otherwise.
virtual bool referentially_equal(const SliceItemPtr &other) const override
Returns true if this slice item has all the same buffers and parameters as other; false otherwise.
int64_t step() const
The step size, which may be negative but must not be zero.
bool preserves_type(const Index64 &advanced) const override
Returns true if this slice would preserve an array's slice and therefore should pass on Content::para...
A sequence of SliceItem objects representing a tuple passed to Python's __getitem__.
Definition: Slice.h:585
void append(const SliceFields &item)
Inserts a SliceFields in-place at the end of the items.
void append(const SliceRange &item)
Inserts a SliceRange in-place at the end of the items.
void append(const SliceItemPtr &item)
Inserts a SliceItem in-place at the end of the items.
void append(const SliceMissing64 &item)
Inserts a SliceMissing64 in-place at the end of the items.
const std::string tostring() const
Returns a string representation of this slice item (single-line custom format).
const Slice tail() const
Returns a Slice representing all but the first SliceItem.
Slice(const std::vector< SliceItemPtr > &items)
Creates an "unsealed" Slice, to which we can still add SliceItem objects (with append).
const Slice only_fields() const
Returns a Slice containing only SliceField and SliceFields.
bool referentially_equal(const Slice &other) const
Returns true if this slice has all the same buffers and parameters as other; false otherwise.
void append(const SliceField &item)
Inserts a SliceField in-place at the end of the items.
const SliceItemPtr head() const
Returns a pointer to the first SliceItem.
void append(const SliceAt &item)
Inserts a SliceAt in-place at the end of the items.
int64_t dimlength() const
The number of SliceAt, SliceRange, and SliceArrayOf objects in the items.
void append(const SliceEllipsis &item)
Inserts a SliceEllipsis in-place at the end of the items.
Slice(const std::vector< SliceItemPtr > &items, bool sealed)
Creates a Slice with a full set of parameters.
void append(const SliceNewAxis &item)
Inserts a SliceNewAxis in-place at the end of the items.
void append(const SliceArray64 &item)
Inserts a SliceArray64 in-place at the end of the items.
static int64_t none()
Represents a missing start, stop, or step in a SliceRange.
bool sealed() const
If true, the Slice is immutable and append will fail. Otherwise, the items may be appended to.
void append(const SliceJagged64 &item)
Inserts a SliceJagged64 in-place at the end of the items.
Slice()
Creates an empty Slice.
void become_sealed()
Seal this Slice so that it is no longer open to append.
const std::vector< SliceItemPtr > items() const
The SliceItem objects in this Slice.
bool isadvanced() const
Returns true if the Slice contains SliceArrayOf; false otherwise.
const Slice prepended(const SliceItemPtr &item) const
Returns a new Slice with item prepended.
int64_t length() const
The number of SliceItem objects in items.
const Slice not_fields() const
Returns a Slice without any SliceField or SliceFields.
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
Definition: BitMaskedArray.h:15
std::shared_ptr< SliceItem > SliceItemPtr
Definition: Slice.h:15