From 0409fd53013c2177044409956e75551a1de62cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Mon, 11 May 2026 13:24:44 +0200 Subject: [PATCH 1/4] Fix the adaptivity data check --- CHANGELOG.md | 1 + micro_manager/micro_manager.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fad2b84b..be419100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fixed `MicroSimulation` initialization requiring positional parameters [#255](https://github.com/precice/micro-manager/pull/255) - Fixed model adaptivity convergence at resolution boundaries to prevent infinite loops for out-of-range switching requests [#252](https://github.com/precice/micro-manager/pull/252) - Add function `set_global_id` to the dummies and the example in the integration test [#247](https://github.com/precice/micro-manager/pull/247) +- Allow `initialize()` to return data that is not used by the adaptivity [#261](https://github.com/precice/micro-manager/pull/261) ## v0.9.0 diff --git a/micro_manager/micro_manager.py b/micro_manager/micro_manager.py index 64239a35..fede0920 100644 --- a/micro_manager/micro_manager.py +++ b/micro_manager/micro_manager.py @@ -742,6 +742,20 @@ def initialize(self) -> None: self._micro_sims[i].initialize() else: # Case where the initialize() method returns data if self._is_adaptivity_on: + # Check for missing data + expected, provided = set(self._data_for_adaptivity.keys()), set( + initial_micro_output.keys() + ) + if missing := expected - provided: + raise Exception( + "The initialize() method needs to return data which is required for the adaptivity calculation. " + f'Of the expected data {", ".join(expected)}, the following is missing: {", ".join(missing)}' + ) + elif extra := provided - expected: + self._logger.log_warning_rank_zero( + f'The initialize() method of the Micro simulation returns extra initial data which isn\'t used by the adaptivity: {", ".join(extra)}' + ) + for name in initial_micro_output.keys(): initial_micro_data[name] = [0] * self._local_number_of_sims # Save initial data from first micro simulation as we anyway have it @@ -753,10 +767,6 @@ def initialize(self) -> None: self._data_for_adaptivity[name][ first_id ] = initial_micro_output[name] - else: - raise Exception( - "The initialize() method needs to return data which is required for the adaptivity calculation." - ) # Gather initial data from the rest of the micro simulations if sim_requires_init_data: From ba1140d0cf415ad68ee4bd522f2b1585b97e93d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Mon, 18 May 2026 11:22:23 +0200 Subject: [PATCH 2/4] Fix adaptivity checks --- micro_manager/micro_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micro_manager/micro_manager.py b/micro_manager/micro_manager.py index fede0920..52c6fe08 100644 --- a/micro_manager/micro_manager.py +++ b/micro_manager/micro_manager.py @@ -743,7 +743,7 @@ def initialize(self) -> None: else: # Case where the initialize() method returns data if self._is_adaptivity_on: # Check for missing data - expected, provided = set(self._data_for_adaptivity.keys()), set( + expected, provided = set(self._adaptivity_micro_data_names), set( initial_micro_output.keys() ) if missing := expected - provided: @@ -751,7 +751,7 @@ def initialize(self) -> None: "The initialize() method needs to return data which is required for the adaptivity calculation. " f'Of the expected data {", ".join(expected)}, the following is missing: {", ".join(missing)}' ) - elif extra := provided - expected: + elif extra := provided - set(self._adaptivity_macro_data_names + self._adaptivity_micro_data_names): self._logger.log_warning_rank_zero( f'The initialize() method of the Micro simulation returns extra initial data which isn\'t used by the adaptivity: {", ".join(extra)}' ) From 0cbea1d53f4a42999c51c0bd301703a587965cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Mon, 18 May 2026 11:26:45 +0200 Subject: [PATCH 3/4] Move changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be419100..0cee45e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,10 @@ ## latest +- Allow `initialize()` to return data that is not used by the adaptivity [#261](https://github.com/precice/micro-manager/pull/261) - Fixed `MicroSimulation` initialization requiring positional parameters [#255](https://github.com/precice/micro-manager/pull/255) - Fixed model adaptivity convergence at resolution boundaries to prevent infinite loops for out-of-range switching requests [#252](https://github.com/precice/micro-manager/pull/252) - Add function `set_global_id` to the dummies and the example in the integration test [#247](https://github.com/precice/micro-manager/pull/247) -- Allow `initialize()` to return data that is not used by the adaptivity [#261](https://github.com/precice/micro-manager/pull/261) ## v0.9.0 From 8a9f0f9d4f4647b402a2ab68822bc761f05f7e36 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 May 2026 13:07:57 +0200 Subject: [PATCH 4/4] Formatting --- micro_manager/micro_manager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/micro_manager/micro_manager.py b/micro_manager/micro_manager.py index 52c6fe08..e5aa1d69 100644 --- a/micro_manager/micro_manager.py +++ b/micro_manager/micro_manager.py @@ -751,7 +751,10 @@ def initialize(self) -> None: "The initialize() method needs to return data which is required for the adaptivity calculation. " f'Of the expected data {", ".join(expected)}, the following is missing: {", ".join(missing)}' ) - elif extra := provided - set(self._adaptivity_macro_data_names + self._adaptivity_micro_data_names): + elif extra := provided - set( + self._adaptivity_macro_data_names + + self._adaptivity_micro_data_names + ): self._logger.log_warning_rank_zero( f'The initialize() method of the Micro simulation returns extra initial data which isn\'t used by the adaptivity: {", ".join(extra)}' )