# colour.utilities.as_int¶

colour.utilities.as_int(a, dtype=None)[source]

Attempts to converts given $$a$$ variable to int using given type.

Parameters
• a (object) – Variable to convert.

• dtype (object) – Type to use for conversion, default to the type defined by the 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.

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]...)