ndonnx.additional package
Module contents
- ndonnx.additional.datetime_to_year_month_day(arr: Array) tuple[Array, Array, Array][source]
Split date time elements of the provided array into year, month, and day components.
- ndonnx.additional.fill_null(x: Array, /, value: Array | SCALAR) Array[source]
Returns a new
Arraywith the null values filled with the given value.- Parameters:
- x: Array
The Array to fill the null values of.
- value: Array | Scalar
The value to fill the null values with.
- Returns:
- out: Array
A new Array with the null values filled with the given value.
- ndonnx.additional.get_data(x: Array, /) Array[source]
Get data part of a masked, datetime or timedelta array.
If the
xis not masked, returnx.
- ndonnx.additional.is_float_dtype(dtype: DType, /) TypeIs[Float16 | Float32 | Float64][source]
Return
Trueifdtypeis of a floating point data type.This does not include masked data types.
- ndonnx.additional.is_integer_dtype(dtype: DType, /) TypeIs[Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64][source]
Return
Trueifdtypeis of an integer data type.Returns
Falsefor boolean data types.
- ndonnx.additional.is_nullable_dtype(dtype: DType, /) TypeIs[NBool | NFloat16 | NFloat32 | NFloat64 | NInt8 | NInt16 | NInt32 | NInt64 | NUInt8 | NUInt16 | NUInt32 | NUInt64 | NUtf8][source]
Return
Trueifdtypeis a nullable (i.e. “masked”) data type.Floating point and datetime data types are not considered as “nullable” by this function.
- ndonnx.additional.is_nullable_float_dtype(dtype: DType, /) TypeIs[NFloat16 | NFloat32 | NFloat64][source]
Return
Trueifdtypeis a nullable integer (i.e. “masked”) data type.
- ndonnx.additional.is_nullable_integer_dtype(dtype: DType, /) TypeIs[NInt8 | NInt16 | NInt32 | NInt64 | NUInt8 | NUInt16 | NUInt32 | NUInt64][source]
Return
Trueifdtypeis a nullable integer (i.e. “masked”) data type.
- ndonnx.additional.is_nullable_numeric_dtype(dtype: DType, /) TypeIs[NFloat16 | NFloat32 | NFloat64 | NInt8 | NInt16 | NInt32 | NInt64 | NUInt8 | NUInt16 | NUInt32 | NUInt64][source]
- ndonnx.additional.is_numeric_dtype(dtype: DType, /) TypeIs[Float16 | Float32 | Float64 | Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64][source]
Return
Trueifdtypeis of a numeric data type.This does not include masked data types.
- ndonnx.additional.is_onnx_dtype(dtype: DType, /) TypeIs[Float16 | Float32 | Float64 | Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64 | Utf8 | Bool][source]
Return
Trueifdtypeis of a data type found in the ONNX standard.
- ndonnx.additional.is_signed_integer_dtype(dtype: DType, /) TypeIs[Int8 | Int16 | Int32 | Int64][source]
Return
Trueifdtypeis of a signed integer data type.Returns
Falsefor boolean data types.
- ndonnx.additional.is_unsigned_integer_dtype(dtype: DType, /) TypeIs[UInt8 | UInt16 | UInt32 | UInt64][source]
Return
Trueifdtypeis of an unsigned integer data type.Returns
Falsefor boolean data types.
- ndonnx.additional.isin(x: Array, /, items: Sequence[SCALAR]) Array[source]
Return true where the input
Arraycontains an element initems.NaNvalues do not compare equal.- Parameters:
- x: Array
The input Array to check for the presence of items.
- items: Sequence[Scalar]
Scalar items to check for in the input Array.
- Returns:
- out: Array
Array of booleans indicating whether each element of
xis initems.
- ndonnx.additional.make_nullable(x: Array, null: Array | None, /, *, merge_strategy: Literal['raise', 'merge'] = 'raise') Array[source]
Given an array
xof values and a null masknull, construct a new Array with a nullable data type.- Parameters:
- x: Array
Array of values
- null: Array
Array of booleans indicating whether each element of
xis null.- merge_strategy: Literal[“raise”, “merge”]
If “raise”, a
TypeErroris raised ifxis already of a nullable data type. If “merge” is provided, any mask existing onxis merged withnull.
- Returns:
- out: Array
A new Array with a nullable data type.
- Raises:
- TypeError
If the data type of
xdoes not have a nullable counterpart.
- ndonnx.additional.put(a: Array, indices: Array, updates: Array, /) None[source]
Replaces specified elements of an array with given values.
This function follows the semantics of numpy.put with `mode=”raises”. The data types of the update array and the updates must match. The indices must be provided as a 1D int64 array.
- ndonnx.additional.shape(x: Array, /) Array[source]
Returns shape of an array.
- Parameters:
- x: Array
Array to get shape of
- Returns:
- out: Array
Array of shape
- ndonnx.additional.static_map(x: Array, /, mapping: Mapping[SCALAR, VALUE], default: VALUE | None = None) Array[source]
Map values in
xbased on the staticmapping.- Parameters:
- x: Array
The Array whose values will be mapped.
- mapping: Mapping[Key, Value]
A mapping from keys to values. The keys must be of the same type as the values in
x.- default: Value, optional
The default value to use when a key is not found in the mapping. If None the value depends on the type of Value in the mapping:
float:
0.0int:
0bool:
Falsestr: “MISSING”
- Returns:
- out: Array
A new Array with the values mapped according to the mapping.
- Raises:
- ValueError
If mapping is empty and default is
None.