colour.utilities.set_float_precision¶
- colour.utilities.set_float_precision(dtype=<class 'numpy.float64'>)[source]¶
Sets Colour float precision by setting
colour.constant.DEFAULT_FLOAT_DTYPE
attribute with given type wherever the attribute is imported.- Parameters
dtype (object) – Type to set
colour.constant.DEFAULT_FLOAT_DTYPE
with.
Warning
Changing float precision might result in various Colour functionality breaking entirely: https://github.com/numpy/numpy/issues/6860. With great power comes great responsibility.
Notes
It is possible to define the float precision at import time by setting the COLOUR_SCIENCE__FLOAT_PRECISION environment variable, for example set COLOUR_SCIENCE__FLOAT_PRECISION=float32.
Some definition returning a single-scalar ndarray might not honour the given float precision: https://github.com/numpy/numpy/issues/16353
Examples
>>> as_float_array(np.ones(3)).dtype dtype('float64') >>> set_float_precision(np.float16) >>> as_float_array(np.ones(3)).dtype dtype('float16') >>> set_float_precision(np.float64) >>> as_float_array(np.ones(3)).dtype dtype('float64')