colour.utilities.as_int#

colour.utilities.as_int(a: float | DTypeFloat, dtype: Type[DTypeInt] | None = None) DTypeInt[source]#
colour.utilities.as_int(a: NDArray | Sequence[int], dtype: Type[DTypeInt] | None = None) NDArrayInt
colour.utilities.as_int(a: ArrayLike, dtype: Type[DTypeInt] | None = None) DTypeInt | NDArrayInt

Convert the specified variable \(a\) to an integer value.

Scalars and 0-dimensional arrays are returned as a Python / NumPy integer scalar. Higher-dimensional arrays go through as_int_array(), which is namespace-aware: when Array API dispatch is enabled and \(a\) is a non-NumPy array, the result is returned in \(a\)’s native namespace.

Parameters:
Returns:

Variable \(a\) converted to an integer scalar or array in the input’s namespace.

Return type:

numpy.integer or numpy.ndarray or backend tensor

Examples

>>> as_int(np.array(1))
np.int64(1)
>>> as_int(np.array([1]))
array([1])
>>> as_int(np.arange(10))
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]...)