colour.utilities.set_default_float_dtype#
- colour.utilities.set_default_float_dtype(dtype: Type[DTypeFloat] = DTYPE_FLOAT_DEFAULT) None[source]#
Set the Colour default
numpy.floatingprecision by settingcolour.constant.DTYPE_FLOAT_DEFAULTattribute with the specifiednumpy.dtypewherever the attribute is imported.- Parameters:
dtype (Type[DTypeFloat]) –
numpy.dtypeto setcolour.constant.DTYPE_FLOAT_DEFAULTwith.- Return type:
None
Notes
It is possible to define the float precision at import time by setting the COLOUR_SCIENCE__DEFAULT_FLOAT_DTYPE environment variable, for example set COLOUR_SCIENCE__DEFAULT_FLOAT_DTYPE=float32.
Some definition returning a single-scalar ndarray might not honour the specified float precision: numpy/numpy#16353
Warning
Changing float precision might result in various Colour functionality breaking entirely: numpy/numpy#6860. With great power comes great responsibility.
Examples
>>> as_float_array(np.ones(3)).dtype dtype('float64') >>> set_default_float_dtype(np.float16) >>> as_float_array(np.ones(3)).dtype dtype('float16') >>> set_default_float_dtype(np.float64) >>> as_float_array(np.ones(3)).dtype dtype('float64')