Skip to content

Commit

Permalink
Rework comments and add CHANGELOG entry
Browse files Browse the repository at this point in the history
  • Loading branch information
IshaanDesai committed May 31, 2024
1 parent e32066a commit 228a4bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## latest

- Handle calling `initialize()` function of micro simulations written in languages other than Python https://github.com/precice/micro-manager/pull/110
- Check if initial data returned from the micro simulation is the data that the adaptivity computation requires https://github.com/precice/micro-manager/pull/109
- Use executable `micro-manager-precice` by default, and stop using the script `run_micro_manager.py` https://github.com/precice/micro-manager/pull/105
- Make `initialize()` method of the MicroManager class public https://github.com/precice/micro-manager/pull/105
Expand Down
13 changes: 7 additions & 6 deletions micro_manager/micro_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,13 @@ def initialize(self) -> None:
if hasattr(micro_problem, "initialize") and callable(
getattr(micro_problem, "initialize")
):
self._micro_sims_init = True
self._micro_sims_init = True # Starting value before setting

# Check if the initialize() method of the micro simulation has any arguments
try: # Try to get the signature of the initialize() method, if it is written in Python
argspec = inspect.getfullargspec(micro_problem.initialize)
if len(argspec.args) == 1:
if (
len(argspec.args) == 1
): # The first argument in the signature is self
is_initial_data_required = False
elif len(argspec.args) == 2:
is_initial_data_required = True
Expand All @@ -485,15 +486,15 @@ def initialize(self) -> None:
self._logger.info(
"The signature of initialize() method of the micro simulation cannot be determined. Trying to determine the signature by calling the method."
)
# Try to call the initialize() method of the micro simulation without arguments. This is necessary if the function is not written in Python.
try:
# Try to get the signature of the initialize() method, if it is not written in Python
try: # Try to call the initialize() method without initial data
self._micro_sims[0].initialize()
is_initial_data_required = False
except TypeError:
self._logger.info(
"The initialize() method of the micro simulation has arguments. Attempting to call it again with initial data."
)
try:
try: # Try to call the initialize() method with initial data
self._micro_sims[0].initialize(initial_data[0])
is_initial_data_required = True
except TypeError:
Expand Down

0 comments on commit 228a4bd

Please sign in to comment.