From 1701c82ef7b320b713350d37abb6caa01c134e0d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 27 May 2026 12:57:48 +0100 Subject: [PATCH 1/2] rewrote lamda as a def --- spinn_utilities/ranged/abstract_list.py | 74 +++++++++++++++++-------- 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/spinn_utilities/ranged/abstract_list.py b/spinn_utilities/ranged/abstract_list.py index 68c8f9fd..b1871164 100644 --- a/spinn_utilities/ranged/abstract_list.py +++ b/spinn_utilities/ranged/abstract_list.py @@ -518,11 +518,16 @@ def __add__(self, other: Union[float, AbstractList[float]] :raises TypeError: """ if isinstance(other, AbstractList): - d_operation: Callable[[Any, float], float] = lambda x, y: x + y - return DualList( - left=self, right=other, operation=d_operation) + + def d_operation(x: Any, y: float) -> float: + return x + y + + return DualList(left=self, right=other, operation=d_operation) if is_number(other): - s_operation: Callable[[Any], float] = lambda x: x + other + + def s_operation(x: any) -> float: + return x + other + return SingleList(a_list=self, operation=s_operation) raise TypeError("__add__ operation only supported for other " "RangedLists and numerical Values") @@ -540,11 +545,16 @@ def __sub__(self, other: Union[float, AbstractList[float]] :raises TypeError: """ if isinstance(other, AbstractList): - d_operation: Callable[[Any, float], float] = lambda x, y: x - y - return DualList( - left=self, right=other, operation=d_operation) + + def d_operation(x: Any, y: float) -> float: + return x - y + + return DualList(left=self, right=other, operation=d_operation) if is_number(other): - s_operation: Callable[[Any], float] = lambda x: x - other + + def s_operation(x: Any) -> float: + return x - other + return SingleList(a_list=self, operation=s_operation) raise TypeError("__sub__ operation only supported for other " "RangedLists and numerical Values") @@ -562,11 +572,16 @@ def __mul__(self, other: Union[float, AbstractList[float]] :raises TypeError: """ if isinstance(other, AbstractList): - d_operation: Callable[[Any, float], float] = lambda x, y: x * y - return DualList( - left=self, right=other, operation=d_operation) + + def d_operation(x: Any, y: float) -> float: + return x * y + + return DualList(left=self, right=other, operation=d_operation) if is_number(other): - s_operation: Callable[[Any], float] = lambda x: x * other + + def s_operation(x: Any) -> float: + return x * other + return SingleList(a_list=self, operation=s_operation) raise TypeError("__mul__ operation only supported for other " "RangedLists and numerical Values") @@ -585,13 +600,18 @@ def __truediv__(self, other: Union[float, AbstractList[float]] :raises TypeError: """ if isinstance(other, AbstractList): - d_operation: Callable[[Any, float], float] = lambda x, y: x / y - return DualList( - left=self, right=other, operation=d_operation) + + def d_operation(x: Any, y: float) -> float: + return x / y + + return DualList(left=self, right=other, operation=d_operation) if is_number(other): if _is_zero(other): raise ZeroDivisionError() - s_operation: Callable[[Any], float] = lambda x: x / other + + def s_operation(x: Any) -> float: + return x / other + return SingleList(a_list=self, operation=s_operation) raise TypeError("__truediv__ operation only supported for other " "RangedLists and numerical Values") @@ -607,19 +627,25 @@ def __floordiv__(self, other: Union[float, AbstractList[float]] :raises TypeError: """ if isinstance(other, AbstractList): - d_operation: Callable[[Any, float], int] = lambda x, y: int(x // y) - return DualList( - left=self, right=other, operation=d_operation) + + def d_operation(x: Any, y: float) -> int: + return int(x // y) + + return DualList(left=self, right=other, operation=d_operation) if is_number(other): if _is_zero(other): raise ZeroDivisionError() - s_operation: Callable[[Any], int] = lambda x: int(x / other) + + def s_operation(x: Any) -> int: + return int(x / other) + return SingleList(a_list=self, operation=s_operation) - raise TypeError("__floordiv__ operation only supported for other " - "RangedLists and numerical Values") + raise TypeError( + "__floordiv__ operation only supported for other " + "RangedLists and numerical Values" + ) - def apply_operation( - self, operation: Callable[[T], U]) -> AbstractList[U]: + def apply_operation(self, operation: Callable[[T], U]) -> AbstractList[U]: """ Applies a function on the list to create a new one. The values of the new list are created on the fly so any changes From 5dd08bc13b83457e5bc4ce237642a429df32f974 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 27 May 2026 16:39:49 +0100 Subject: [PATCH 2/2] Any --- spinn_utilities/ranged/abstract_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinn_utilities/ranged/abstract_list.py b/spinn_utilities/ranged/abstract_list.py index b1871164..312c7889 100644 --- a/spinn_utilities/ranged/abstract_list.py +++ b/spinn_utilities/ranged/abstract_list.py @@ -525,7 +525,7 @@ def d_operation(x: Any, y: float) -> float: return DualList(left=self, right=other, operation=d_operation) if is_number(other): - def s_operation(x: any) -> float: + def s_operation(x: Any) -> float: return x + other return SingleList(a_list=self, operation=s_operation)