Constructors¶
The main strategy arrays().
The function arrays() is the main strategy of this package. It generates Awkward
Arrays with multiple options to control the layout, data types, missing values, masks,
and other array attributes.
Functions:
| Name | Description |
|---|---|
arrays |
Strategy for Awkward Arrays. |
arrays ¶
arrays(
draw: DrawFn,
*,
dtypes: SearchStrategy[dtype] | None = None,
max_size: int = 50,
allow_nan: bool = True,
allow_numpy: bool = True,
allow_empty: bool = True,
allow_string: bool = True,
allow_bytestring: bool = True,
allow_regular: bool = True,
allow_list_offset: bool = True,
allow_list: bool = True,
allow_record: bool = True,
allow_union: bool = True,
allow_indexed_option: bool = True,
allow_byte_masked: bool = True,
allow_bit_masked: bool = True,
allow_unmasked: bool = True,
max_leaf_size: int | None = None,
max_depth: int | None = None,
max_length: int | None = None,
allow_virtual: bool = True,
) -> ak.Array
Strategy for Awkward Arrays.
This is the main strategy in this package. It is under development. The aim is to generate fully general Awkward Arrays, with many options to control layout, data types, missing values, masks, and other array attributes.
In constructing arrays, this strategy follows the Awkward Array User Guide section
"Direct constructors". It constructs layouts and
wraps them in an ak.Array. The layouts are instances of subclasses
of ak.contents.Content.
By default, when called with no arguments, arrays() generates the most general
arrays currently implemented, subject to a finite maximum size. Arguments can be
provided to exclude certain layouts or data types, or to constrain values and sizes.
The current implementation generates arrays with the following layouts:
EmptyArrayNumpyArrayRegularArrayListArrayListOffsetArray- Strings
- Bytestrings
RecordArrayIndexedOptionArrayByteMaskedArrayBitMaskedArrayUnmaskedArrayUnionArray
Each type can be excluded separately with the corresponding allow_* argument.
The max_size is the main argument for constraining the array size. It counts most
of the scalar values in the layout, including data elements, offsets, indices, field
names, and parameters. The array size can also be constrained with
max_leaf_size, max_depth, and max_length.
The arrays() randomly generates virtual arrays by lazifying buffers. The
allow_virtual can be used to disable virtual arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtypes
|
SearchStrategy[dtype] | None
|
A strategy for NumPy scalar dtypes used in |
None
|
max_size
|
int
|
Upper bound on the number of scalars in the generated content. Counts data elements, offsets, indices, field names, and parameters. |
50
|
allow_nan
|
bool
|
No |
True
|
allow_numpy
|
bool
|
No |
True
|
allow_empty
|
bool
|
No |
True
|
allow_string
|
bool
|
No string content is generated if |
True
|
allow_bytestring
|
bool
|
No bytestring content is generated if |
True
|
allow_regular
|
bool
|
No |
True
|
allow_list_offset
|
bool
|
No |
True
|
allow_list
|
bool
|
No |
True
|
allow_record
|
bool
|
No |
True
|
allow_union
|
bool
|
No |
True
|
allow_indexed_option
|
bool
|
No |
True
|
allow_byte_masked
|
bool
|
No |
True
|
allow_bit_masked
|
bool
|
No |
True
|
allow_unmasked
|
bool
|
No |
True
|
max_leaf_size
|
int | None
|
Maximum total number of leaf elements in the generated content. Each numerical value, including complex and datetime, counts as one. Each string and bytestring (not character or byte) counts as one. |
None
|
max_depth
|
int | None
|
Maximum nesting depth. Each |
None
|
max_length
|
int | None
|
Maximum |
None
|
allow_virtual
|
bool
|
No virtual arrays are generated if |
True
|
Examples: