# colour.utilities.as_float¶

colour.utilities.as_float(a)[source]

Converts given $$a$$ variable to numeric using the type defined by colour.constant.DEFAULT_FLOAT_DTYPE attribute. In the event where $$a$$ cannot be converted, it is converted to ndarray using the type defined by colour.constant.DEFAULT_FLOAT_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_FLOAT_DTYPE attribute while the later will pass the $$a$$ variable as is.

Examples

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