NumPy¶
Strategies related to NumPy in the context of Awkward Array.
These strategies are related to the section of Awkward Array User Guide "How to convert to/from NumPy".
Functions:
| Name | Description |
|---|---|
supported_dtype_names |
Strategy for names of NumPy dtypes supported by Awkward Array. |
supported_dtypes |
Strategy for NumPy dtypes supported by Awkward Array. |
numpy_dtypes |
Strategy for dtypes (simple or array) supported by Awkward Array. |
numpy_arrays |
Strategy for NumPy arrays from which Awkward Arrays can be created. |
from_numpy |
Strategy for Awkward Arrays created from NumPy arrays. |
supported_dtype_names ¶
supported_dtypes ¶
numpy_dtypes ¶
numpy_dtypes(
*,
dtype: dtype | SearchStrategy[dtype] | None = None,
allow_array: bool = True,
max_size: int = 5,
) -> st.SearchStrategy[np.dtype]
Strategy for dtypes (simple or array) supported by Awkward Array.
Examples of simple dtypes are dtype('int32'), dtype('float64')
Array dtypes include ([('f0', 'i4'), ('f1', 'f8')]). They are dtypes of structured NumPy arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
dtype | SearchStrategy[dtype] | None
|
A simple dtype or a strategy for simple dtypes for determining the type of
array elements. If |
None
|
allow_array
|
bool
|
Generate only simple dtypes if |
True
|
max_size
|
int
|
Maximum number of scalars in a structured dtype. |
5
|
Examples:
numpy_arrays ¶
numpy_arrays(
draw: DrawFn,
*,
dtype: dtype | SearchStrategy[dtype] | None = None,
allow_structured: bool = True,
allow_nan: bool = False,
min_dims: int = 1,
max_dims: int | None = None,
min_size: int = 0,
max_size: int = 10,
) -> np.ndarray
Strategy for NumPy arrays from which Awkward Arrays can be created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
dtype | SearchStrategy[dtype] | None
|
A simple dtype or a strategy for simple dtypes for determining the type of
array elements. If |
None
|
allow_structured
|
bool
|
Generate only simple arrays if |
True
|
allow_nan
|
bool
|
Generate potentially |
False
|
min_dims
|
int
|
Minimum number of dimensions. |
1
|
max_dims
|
int | None
|
Maximum number of dimensions. If |
None
|
min_size
|
int
|
Minimum number of scalars in the array. For structured dtypes, each element counts as multiple scalars (one per field). |
0
|
max_size
|
int
|
Maximum number of scalars in the array. For structured dtypes, each element counts as multiple scalars (one per field). |
10
|
Examples:
from_numpy ¶
from_numpy(
*,
dtype: dtype | SearchStrategy[dtype] | None = None,
allow_structured: bool = True,
allow_nan: bool = False,
regulararray: bool | None = None,
max_size: int = 10,
) -> st.SearchStrategy[ak.Array]
Strategy for Awkward Arrays created from NumPy arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
dtype | SearchStrategy[dtype] | None
|
A simple dtype or a strategy for simple dtypes for determining the type of
array elements. If |
None
|
allow_structured
|
bool
|
Generate only from simple NumPy arrays if |
True
|
allow_nan
|
bool
|
Generate potentially |
False
|
regulararray
|
bool | None
|
Passed to |
None
|
max_size
|
int
|
Maximum number of scalars in the array. For structured dtypes, each element counts as multiple scalars (one per field). |
10
|
Examples: