colour.utilities.as_numeric

colour.utilities.as_numeric(a, dtype=<class 'numpy.float64'>)[source]

Converts given \(a\) variable to numeric. In the event where \(a\) cannot be converted, it is passed as is.

Parameters:
  • a (object) – Variable to convert.
  • dtype (object) – Type to use for conversion.
Returns:

\(a\) variable converted to numeric.

Return type:

ndarray

Examples

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