From 5005de06ceb34abb181b5dd03dacc6a6d70dc907 Mon Sep 17 00:00:00 2001 From: xuzhaozheng Date: Wed, 25 Dec 2024 17:19:33 +0800 Subject: [PATCH] Change xyY_to_XYZ function to prevent negative floating point error in some cases. Python Example: 1 - 0.680 - 0.320 = -5.551115123125783e-17; 1 - (0.680 + 0.320) = 0.0 --- colour/models/cie_xyy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colour/models/cie_xyy.py b/colour/models/cie_xyy.py index 1e17c0b62..d47cac2a2 100644 --- a/colour/models/cie_xyy.py +++ b/colour/models/cie_xyy.py @@ -149,7 +149,7 @@ def xyY_to_XYZ(xyY: ArrayLike) -> NDArrayFloat: with sdiv_mode(): Y_y = sdiv(Y, y) - XYZ = tstack([x * Y_y, Y, (1 - x - y) * Y_y]) + XYZ = tstack([x * Y_y, Y, (1 - (x + y)) * Y_y]) return from_range_1(XYZ)