From 7a6d356345a9c4969859cd89e67e33be1fe9905a Mon Sep 17 00:00:00 2001 From: Torben Schiz Date: Thu, 28 Mar 2024 16:34:44 +0100 Subject: [PATCH] Fix typo, remove redundent code and replace __import__ --- micro_manager/micro_manager.py | 7 +++---- tests/unit/test_micro_manager.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/micro_manager/micro_manager.py b/micro_manager/micro_manager.py index 28ca71a8..704e8196 100644 --- a/micro_manager/micro_manager.py +++ b/micro_manager/micro_manager.py @@ -19,6 +19,7 @@ import numpy as np import logging import time +import importlib from copy import deepcopy from typing import Dict from warnings import warn @@ -71,8 +72,6 @@ def __init__(self, config_file: str) -> None: self._rank, self._size) - micro_file_name = self._config.get_micro_file_name() - self._macro_mesh_name = self._config.get_macro_mesh_name() # Data names of data written to preCICE @@ -309,9 +308,9 @@ def _initialize(self) -> None: self._micro_sims = [None] * self._local_number_of_sims # DECLARATION micro_problem = getattr( - __import__( + importlib.import_module( self._config.get_micro_file_name(), - fromlist=["MicroSimulation"]), + "MicroSimulation"), "MicroSimulation") # Create micro simulation objects diff --git a/tests/unit/test_micro_manager.py b/tests/unit/test_micro_manager.py index 55548cc7..b6a43e1f 100644 --- a/tests/unit/test_micro_manager.py +++ b/tests/unit/test_micro_manager.py @@ -75,7 +75,7 @@ def test_read_write_data_from_precice(self): self.assertListEqual(data["macro-vector-data"].tolist(), fake_data["macro-vector-data"].tolist()) - def test_solve_mico_sims(self): + def test_solve_micro_sims(self): """ Test if the internal function _solve_micro_simulations works as expected. """