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 numpy.integer using the specified numpy.dtype.

The function converts variable \(a\) to an integer type. If variable \(a\) is not a scalar or 0-dimensional array, it is converted to numpy.ndarray.

Parameters:
Returns:

Variable \(a\) converted to numpy.integer.

Return type:

numpy.ndarray

Examples

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