From c79910b2cde62e8e369f4595845278e486f6cf33 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Thu, 4 Dec 2025 13:55:28 +0000 Subject: [PATCH 1/2] Implement selectElements for Python MatrixLib implementation Must've missed it in https://github.com/eclipse-agileuml/agileuml/pull/16 and https://github.com/eclipse-agileuml/agileuml/pull/21 --- libraries/matrixlib.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/matrixlib.py b/libraries/matrixlib.py index 24a5a512..92cef280 100644 --- a/libraries/matrixlib.py +++ b/libraries/matrixlib.py @@ -126,6 +126,11 @@ def elementwiseApply(m: list, f: callable) -> list: return [MatrixLib.elementwiseApply(list(_r), f) for _r in m] return [f(float(z)) for z in m] + def selectElements(m: list, f: callable) -> list: + if len(m) == 0: return [] + elif isinstance(m[0], list): return [MatrixLib.selectElements(list(_r), f) for _r in m] + else: [float(z) for z in m if f(float(z))] + def elementwiseNot(m: list) -> list: if len(m) == 0: return [] From 73a46192dae23263c6826d8aae5b2644e42c1f7d Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Thu, 4 Dec 2025 18:56:00 +0000 Subject: [PATCH 2/2] Add missing return statement to else condition --- libraries/matrixlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/matrixlib.py b/libraries/matrixlib.py index 92cef280..b3d5cc27 100644 --- a/libraries/matrixlib.py +++ b/libraries/matrixlib.py @@ -129,7 +129,7 @@ def elementwiseApply(m: list, f: callable) -> list: def selectElements(m: list, f: callable) -> list: if len(m) == 0: return [] elif isinstance(m[0], list): return [MatrixLib.selectElements(list(_r), f) for _r in m] - else: [float(z) for z in m if f(float(z))] + else: return [float(z) for z in m if f(float(z))] def elementwiseNot(m: list) -> list: if len(m) == 0: