colour.utilities.as_int¶
- colour.utilities.as_int(a: NumberOrArrayLike, dtype: Optional[Type[DTypeInteger]] = None) IntegerOrNDArray [source]¶
Attempt to convert given variable \(a\) to
numpy.integer
using givennumpy.dtype
. If variable \(a\) is not a scalar or 0-dimensional, it is converted tonumpy.ndarray
.- Parameters
a (NumberOrArrayLike) – Variable to convert.
dtype (Optional[Type[DTypeInteger]]) –
numpy.dtype
to use for conversion, default to thenumpy.dtype
defined by thecolour.constant.DEFAULT_INT_DTYPE
attribute.
- Returns
Variable \(a\) converted to
numpy.integer
.- Return type
Examples
>>> as_int(np.array([1])) 1 >>> as_int(np.arange(10)) array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]...)