colour.utilities.as_int

colour.utilities.as_int(a)[source]

Converts given \(a\) variable to numeric using the type defined by colour.constant.DEFAULT_INT_DTYPE attribute. In the event where \(a\) cannot be converted, it is converted to ndarray using the type defined by colour.constant.DEFAULT_INT_DTYPE attribute.

Parameters:a (object) – Variable to convert.
Returns:\(a\) variable converted to numeric.
Return type:ndarray

Warning

The behaviour of this definition is different than colour.utilities.as_numeric() definition when it comes to conversion failure: the former will forcibly convert \(a\) variable to ndarray using the type defined by colour.constant.DEFAULT_INT_DTYPE attribute while the later will pass the \(a\) variable as is.

Examples

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