EmptyArray.h
Go to the documentation of this file.
1 // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
2 
3 #ifndef AWKWARD_EMPTYARRAY_H_
4 #define AWKWARD_EMPTYARRAY_H_
5 
6 #include <string>
7 #include <memory>
8 #include <vector>
9 
10 #include "awkward/common.h"
11 #include "awkward/Slice.h"
12 #include "awkward/Content.h"
13 
14 namespace awkward {
15  class NumpyArray;
16 
21  public:
23  EmptyForm(bool has_identities,
24  const util::Parameters& parameters,
25  const FormKey& form_key);
26 
27  const TypePtr
28  type(const util::TypeStrs& typestrs) const override;
29 
30  void
31  tojson_part(ToJson& builder, bool verbose) const override;
32 
33  const FormPtr
34  shallow_copy() const override;
35 
36  const FormPtr
37  with_form_key(const FormKey& form_key) const override;
38 
39  const std::string
40  purelist_parameter(const std::string& key) const override;
41 
42  bool
43  purelist_isregular() const override;
44 
45  int64_t
46  purelist_depth() const override;
47 
48  bool
49  dimension_optiontype() const override;
50 
51  const std::pair<int64_t, int64_t>
52  minmax_depth() const override;
53 
54  const std::pair<bool, int64_t>
55  branch_depth() const override;
56 
57  int64_t
58  numfields() const override;
59 
60  int64_t
61  fieldindex(const std::string& key) const override;
62 
63  const std::string
64  key(int64_t fieldindex) const override;
65 
66  bool
67  haskey(const std::string& key) const override;
68 
69  const std::vector<std::string>
70  keys() const override;
71 
72  bool
73  istuple() const override;
74 
75  bool
76  equal(const FormPtr& other,
77  bool check_identities,
78  bool check_parameters,
79  bool check_form_key,
80  bool compatibility_check) const override;
81 
82  const FormPtr
83  getitem_field(const std::string& key) const override;
84 
85  const FormPtr
86  getitem_fields(const std::vector<std::string>& keys) const override;
87 
88  };
89 
97  public:
104  EmptyArray(const IdentitiesPtr& identities,
105  const util::Parameters& parameters);
106 
109  const std::shared_ptr<NumpyArray>
110  toNumpyArray(const std::string& format,
111  ssize_t itemsize,
112  util::dtype npdtype) const;
113 
115  const std::string
116  classname() const override;
117 
118  void
119  setidentities() override;
120 
121  void
122  setidentities(const IdentitiesPtr& identities) override;
123 
124  const TypePtr
125  type(const util::TypeStrs& typestrs) const override;
126 
127  const FormPtr
128  form(bool materialize) const override;
129 
131  kernels() const override;
132 
133  void
134  caches(std::vector<ArrayCachePtr>& out) const override;
135 
136  const std::string
137  tostring_part(const std::string& indent,
138  const std::string& pre,
139  const std::string& post) const override;
140 
141  void
142  tojson_part(ToJson& builder, bool include_beginendlist) const override;
143 
144  void
145  nbytes_part(std::map<size_t, int64_t>& largest) const override;
146 
147  int64_t
148  length() const override;
149 
150  const ContentPtr
151  shallow_copy() const override;
152 
153  const ContentPtr
154  deep_copy(bool copyarrays,
155  bool copyindexes,
156  bool copyidentities) const override;
157 
158  void
159  check_for_iteration() const override;
160 
161  const ContentPtr
162  getitem_nothing() const override;
163 
164  const ContentPtr
165  getitem_at(int64_t at) const override;
166 
167  const ContentPtr
168  getitem_at_nowrap(int64_t at) const override;
169 
170  const ContentPtr
171  getitem_range(int64_t start, int64_t stop) const override;
172 
173  const ContentPtr
174  getitem_range_nowrap(int64_t start, int64_t stop) const override;
175 
176  const ContentPtr
177  getitem_field(const std::string& key) const override;
178 
179  const ContentPtr
180  getitem_field(const std::string& key,
181  const Slice& only_fields) const override;
182 
183  const ContentPtr
184  getitem_fields(const std::vector<std::string>& keys) const override;
185 
186  const ContentPtr
187  getitem_fields(const std::vector<std::string>& keys,
188  const Slice& only_fields) const override;
189 
190  const ContentPtr
191  carry(const Index64& carry, bool allow_lazy) const override;
192 
193  int64_t
194  purelist_depth() const override;
195 
196  const std::pair<int64_t, int64_t>
197  minmax_depth() const override;
198 
199  const std::pair<bool, int64_t>
200  branch_depth() const override;
201 
202  int64_t
203  numfields() const override;
204 
205  int64_t
206  fieldindex(const std::string& key) const override;
207 
208  const std::string
209  key(int64_t fieldindex) const override;
210 
211  bool
212  haskey(const std::string& key) const override;
213 
214  const std::vector<std::string>
215  keys() const override;
216 
217  bool
218  istuple() const override;
219 
220  // operations
221  const std::string
222  validityerror(const std::string& path) const override;
223 
227  const ContentPtr
228  shallow_simplify() const override;
229 
230  const ContentPtr
231  num(int64_t axis, int64_t depth) const override;
232 
233  const std::pair<Index64, ContentPtr>
234  offsets_and_flattened(int64_t axis, int64_t depth) const override;
235 
236  bool
237  mergeable(const ContentPtr& other, bool mergebool) const override;
238 
239  bool
240  referentially_equal(const ContentPtr& other) const override;
241 
242  const ContentPtr
243  mergemany(const ContentPtrVec& others) const override;
244 
245  const SliceItemPtr
246  asslice() const override;
247 
248  const ContentPtr
249  fillna(const ContentPtr& value) const override;
250 
251  const ContentPtr
252  rpad(int64_t target, int64_t axis, int64_t depth) const override;
253 
254  const ContentPtr
255  rpad_and_clip(int64_t target,
256  int64_t axis,
257  int64_t depth) const override;
258 
259  const ContentPtr
260  reduce_next(const Reducer& reducer,
261  int64_t negaxis,
262  const Index64& starts,
263  const Index64& shifts,
264  const Index64& parents,
265  int64_t outlength,
266  bool mask,
267  bool keepdims) const override;
268 
269  const ContentPtr
270  sort_next(int64_t negaxis,
271  const Index64& starts,
272  const Index64& parents,
273  int64_t outlength,
274  bool ascending,
275  bool stable) const override;
276 
277  const ContentPtr
278  argsort_next(int64_t negaxis,
279  const Index64& starts,
280  const Index64& shifts,
281  const Index64& parents,
282  int64_t outlength,
283  bool ascending,
284  bool stable) const override;
285 
286  const ContentPtr
287  localindex(int64_t axis, int64_t depth) const override;
288 
289  const ContentPtr
290  combinations(int64_t n,
291  bool replacement,
292  const util::RecordLookupPtr& recordlookup,
293  const util::Parameters& parameters,
294  int64_t axis,
295  int64_t depth) const override;
296 
297  const ContentPtr
298  getitem_next(const SliceAt& at,
299  const Slice& tail,
300  const Index64& advanced) const override;
301 
302  const ContentPtr
303  getitem_next(const SliceRange& range,
304  const Slice& tail,
305  const Index64& advanced) const override;
306 
307  const ContentPtr
308  getitem_next(const SliceArray64& array,
309  const Slice& tail,
310  const Index64& advanced) const override;
311 
312  const ContentPtr
313  getitem_next(const SliceField& field,
314  const Slice& tail,
315  const Index64& advanced) const override;
316 
317  const ContentPtr
318  getitem_next(const SliceFields& fields,
319  const Slice& tail,
320  const Index64& advanced) const override;
321 
322  const ContentPtr
323  getitem_next(const SliceJagged64& jagged,
324  const Slice& tail,
325  const Index64& advanced) const override;
326 
327  const ContentPtr
328  getitem_next_jagged(const Index64& slicestarts,
329  const Index64& slicestops,
330  const SliceArray64& slicecontent,
331  const Slice& tail) const override;
332 
333  const ContentPtr
334  getitem_next_jagged(const Index64& slicestarts,
335  const Index64& slicestops,
336  const SliceMissing64& slicecontent,
337  const Slice& tail) const override;
338 
339  const ContentPtr
340  getitem_next_jagged(const Index64& slicestarts,
341  const Index64& slicestops,
342  const SliceJagged64& slicecontent,
343  const Slice& tail) const override;
344 
345  const ContentPtr
346  copy_to(kernel::lib ptr_lib) const override;
347 
348  const ContentPtr
349  numbers_to_type(const std::string& name) const override;
350 
352  bool
353  is_unique() const override;
354 
356  const ContentPtr
357  unique() const override;
358 
360  bool
361  is_subrange_equal(const Index64& start, const Index64& stop) const override;
362 
363  };
364 
365 }
366 
367 #endif // AWKWARD_EMPTYARRAY_H_
Represents a Python slice object (usual syntax: array[start:stop:step]).
Definition: Slice.h:93
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
const std::string key(const RecordLookupPtr &recordlookup, int64_t fieldindex, int64_t numfields)
Returns the key associated with a field index, given a RecordLookup and a number of fields...
Abstract superclass of all array node types (flat hierarchy). Any Content can be nested within any ot...
Definition: Content.h:276
Definition: json.h:19
Definition: BitMaskedArray.h:15
A contiguous, one-dimensional array of integers used to represent data structures, rather than numerical data in the arrays themselves.
Definition: Index.h:16
std::string name(Mapping a, V value)
Definition: datetime_util.h:39
Definition: Slice.h:384
Represents a SliceArrayOf, SliceMissingOf, or SliceJaggedOf with missing values: None (no equivalent ...
Definition: Slice.h:431
Represents a single string in a slice tuple, indicating that a RecordArray should be replaced by one ...
Definition: Slice.h:340
Abstract class for all reducer algorithms.
Definition: Reducer.h:20
ERROR combinations(kernel::lib ptr_lib, T *toindex, int64_t n, bool replacement, int64_t singlelen)
const std::vector< std::string > keys(const RecordLookupPtr &recordlookup, int64_t numfields)
Returns a given RecordLookup as keys or generate anonymous ones form a number of fields.
Form describing EmptyArray.
Definition: EmptyArray.h:20
std::shared_ptr< std::string > FormKey
Definition: Content.h:19
dtype
NumPy dtypes that can be interpreted within Awkward C++ (only the primitive, fixed-width types)...
Definition: util.h:26
ERROR unique(kernel::lib ptr_lib, T *toptr, int64_t length, int64_t *tolength)
Represents an array with length zero and (perhaps as a consequence) UnknownType.
Definition: EmptyArray.h:96
Represents an array of integers in a slice (possibly converted from an array of booleans).
Definition: Slice.h:225
std::map< std::string, std::string > Parameters
Definition: util.h:165
ERROR copy_to(kernel::lib to_lib, kernel::lib from_lib, void *to_ptr, void *from_ptr, int64_t bytelength)
Internal Function an array buffer from library FROM to library TO, usually between main memory and a ...
std::shared_ptr< Form > FormPtr
Definition: Content.h:18
int64_t fieldindex(const RecordLookupPtr &recordlookup, const std::string &key, int64_t numfields)
Returns the field index associated with a key, given a RecordLookup and a number of fields...
Represents an array of nested lists, where the content may be SliceArrayOf, SliceMissingOf, or SliceJaggedOf (no equivalent in NumPy).
Definition: Slice.h:511
std::vector< std::shared_ptr< Content > > ContentPtrVec
Definition: Content.h:16
Mapping::value_type::value_type value(Mapping a, const std::string &name)
Definition: datetime_util.h:49
A sequence of SliceItem objects representing a tuple passed to Python&#39;s __getitem__.
Definition: Slice.h:585
bool haskey(const RecordLookupPtr &recordlookup, const std::string &key, int64_t numfields)
Returns true if a RecordLookup has a given key; false otherwise.
std::shared_ptr< Type > TypePtr
Definition: Content.h:23
std::shared_ptr< RecordLookup > RecordLookupPtr
Definition: util.h:130
Represents an integer in a tuple of slices passed to __getitem__ in Python.
Definition: Slice.h:58
std::map< std::string, std::string > TypeStrs
Definition: util.h:215
Abstract superclass of all array node forms, which expresses the nesting structure without any large ...
Definition: Content.h:39
std::shared_ptr< Identities > IdentitiesPtr
Definition: Identities.h:16
std::shared_ptr< Content > ContentPtr
Definition: ArrayBuilder.h:16
std::shared_ptr< SliceItem > SliceItemPtr
Definition: Slice.h:15
lib
Definition: kernel-dispatch.h:20