colour.utilities.as_int#
- colour.utilities.as_int(a: ArrayLike, dtype: Type[DTypeInt] | None = None) NDArrayInt[source]#
Attempt to convert given variable \(a\) to
numpy.integerusing givennumpy.dtype. If variable \(a\) is not a scalar or 0-dimensional, it is converted tonumpy.ndarray.- Parameters:
a (ArrayLike) – Variable \(a\) to convert.
dtype (Type[DTypeInt] | None) –
numpy.dtypeto use for conversion, default to thenumpy.dtypedefined by thecolour.constant.DTYPE_INT_DEFAULTattribute.
- Returns:
Variable \(a\) converted to
numpy.integer.- Return type:
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]...)