From 63eb521eb282bf1cc8a8fd340b347fd373ec3cb4 Mon Sep 17 00:00:00 2001 From: connoraird Date: Thu, 29 Jan 2026 09:51:31 +0000 Subject: [PATCH 1/2] Fix var to be array api compatible by using float64 for __truediv__ --- transformcl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transformcl.py b/transformcl.py index 581189e..5817575 100644 --- a/transformcl.py +++ b/transformcl.py @@ -138,7 +138,7 @@ def var(cl): """ xp = array_namespace(cl) - ell = xp.arange(cl.shape[-1]) + ell = xp.arange(cl.shape[-1], dtype=xp.float64) return xp.sum((2 * ell + 1) / (4 * xp.pi) * cl, axis=-1) From bbe5d21816df7ee6c7b43f6cd97b9a05306a3d35 Mon Sep 17 00:00:00 2001 From: connoraird Date: Thu, 29 Jan 2026 09:58:59 +0000 Subject: [PATCH 2/2] Add comment to explain change --- transformcl.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/transformcl.py b/transformcl.py index 5817575..1bd29b1 100644 --- a/transformcl.py +++ b/transformcl.py @@ -138,6 +138,8 @@ def var(cl): """ xp = array_namespace(cl) + # ell cannot be an integer here as, within the array api + # only floating-point dtypes are allowed in __truediv__ ell = xp.arange(cl.shape[-1], dtype=xp.float64) return xp.sum((2 * ell + 1) / (4 * xp.pi) * cl, axis=-1)