From fcacf4f26686680ed1c5d5f273b7e36fc515c572 Mon Sep 17 00:00:00 2001 From: Gilberto RUIZ JIMENEZ Date: Mon, 10 Nov 2025 11:55:34 +0100 Subject: [PATCH 1/2] refactor(Comparisons): support string arrays with more than one component in compare_dict_of_arrays Signed-off-by: Gilberto RUIZ JIMENEZ --- src/gemseo/utils/comparisons.py | 2 +- tests/utils/test_comparisons.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gemseo/utils/comparisons.py b/src/gemseo/utils/comparisons.py index d2a8f90e2c..578cdac8f7 100644 --- a/src/gemseo/utils/comparisons.py +++ b/src/gemseo/utils/comparisons.py @@ -111,7 +111,7 @@ def compare_dict_of_arrays( other_array = other_array.data.reshape(-1) if array_.dtype.type is str_: - if array_ != other_array: + if (array_ != other_array).any(): return False elif not compare_arrays(array_, other_array): return False diff --git a/tests/utils/test_comparisons.py b/tests/utils/test_comparisons.py index 00993759aa..6796359f39 100644 --- a/tests/utils/test_comparisons.py +++ b/tests/utils/test_comparisons.py @@ -118,6 +118,8 @@ def test_array_are_close( ("string", "bad", False), (array(["string"]), array(["string"]), True), (array(["string"]), array(["bad"]), False), + (array(["string", "other_string"]), array(["string", "other_string"]), True), + (array(["string", "other_string"]), array(["string", "bad"]), False), ("string", array(["string"]), False), ], ) -- GitLab From 275e7d830e27289df6468fef0ea6e12cc48736c4 Mon Sep 17 00:00:00 2001 From: Gilberto RUIZ JIMENEZ Date: Mon, 10 Nov 2025 13:39:53 +0100 Subject: [PATCH 2/2] docs(Changelog): update the changelog Signed-off-by: Gilberto RUIZ JIMENEZ --- changelog/fragments/1662.fixed.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/fragments/1662.fixed.rst diff --git a/changelog/fragments/1662.fixed.rst b/changelog/fragments/1662.fixed.rst new file mode 100644 index 0000000000..972f51a39c --- /dev/null +++ b/changelog/fragments/1662.fixed.rst @@ -0,0 +1 @@ +The ``compare_dict_of_arrays`` function now works witth arrays of string with multiple components. -- GitLab