colour.utilities.set_default_float_dtype¶
- colour.utilities.set_default_float_dtype()[source]¶
Set Colour default
numpy.floating
precision by settingcolour.constant.DEFAULT_FLOAT_DTYPE
attribute with givennumpy.dtype
wherever the attribute is imported.- Parameters
dtype –
numpy.dtype
to setcolour.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__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 given float precision: https://github.com/numpy/numpy/issues/16353
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')