diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 80021f1..ba06a37 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,7 +17,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-13, windows-latest] python-version: ["3.8", "3.10"] defaults: run: @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v4 - name: Set up conda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: python-version: ${{ matrix.python-version }} auto-update-conda: true diff --git a/oommfc/drivers/driver.py b/oommfc/drivers/driver.py index 78e13e2..a77f534 100644 --- a/oommfc/drivers/driver.py +++ b/oommfc/drivers/driver.py @@ -21,8 +21,13 @@ def __init__(self, **kwargs): self.autoselect_evolver = True @abc.abstractmethod - def _checkargs(self, **kwargs): - """Abstract method for checking arguments.""" + def _checkargs(self, kwargs) -> dict: + """Check drive keyword arguments. + + This method can also update keyword arguments where required. It must return + a dict of all keyword arguments (initial or modified) that shall be used for the + simulation. + """ def drive_kwargs_setup(self, drive_kwargs): """Additional keyword arguments allowed for drive. @@ -56,7 +61,7 @@ def drive_kwargs_setup(self, drive_kwargs): save additional data. Defaults to ``None``. """ - self._checkargs(**drive_kwargs) + drive_kwargs = self._checkargs(drive_kwargs) drive_kwargs.setdefault("fixed_subregions", None) drive_kwargs.setdefault("output_step", False) drive_kwargs.setdefault("n_threads", None) @@ -98,7 +103,7 @@ def schedule_kwargs_setup(self, schedule_kwargs): save additional data. Defaults to ``None``. """ - self._checkargs(**schedule_kwargs) + schedule_kwargs = self._checkargs(schedule_kwargs) schedule_kwargs.setdefault("fixed_subregions", None) schedule_kwargs.setdefault("output_step", False) schedule_kwargs.setdefault("compute", None) diff --git a/oommfc/drivers/hysteresisdriver.py b/oommfc/drivers/hysteresisdriver.py index 69a2fc5..7aa8ba3 100644 --- a/oommfc/drivers/hysteresisdriver.py +++ b/oommfc/drivers/hysteresisdriver.py @@ -58,7 +58,7 @@ class HysteresisDriver(Driver): "report_wall_time", ] - def _checkargs(self, **kwargs): + def _checkargs(self, kwargs): Hmin, Hmax, n = kwargs["Hmin"], kwargs["Hmax"], kwargs["n"] for i in [Hmin, Hmax]: if not isinstance(i, (list, tuple, np.ndarray)): @@ -73,6 +73,7 @@ def _checkargs(self, **kwargs): if n - 1 <= 0: # OOMMF counts steps, not points (n -> n-1) msg = f"Cannot drive with {n=}." raise ValueError(msg) + return kwargs def _check_system(self, system): """Checks the system has energy in it""" diff --git a/oommfc/drivers/mindriver.py b/oommfc/drivers/mindriver.py index 413d275..a04b9aa 100644 --- a/oommfc/drivers/mindriver.py +++ b/oommfc/drivers/mindriver.py @@ -56,8 +56,8 @@ class MinDriver(Driver): "report_wall_time", ] - def _checkargs(self, **kwargs): - pass # no kwargs should be checked + def _checkargs(self, kwargs): + return kwargs # no kwargs should be checked def _check_system(self, system): """Checks the system has energy in it""" diff --git a/oommfc/drivers/timedriver.py b/oommfc/drivers/timedriver.py index 328cdef..3df8070 100644 --- a/oommfc/drivers/timedriver.py +++ b/oommfc/drivers/timedriver.py @@ -55,7 +55,7 @@ class TimeDriver(Driver): "report_wall_time", ] - def _checkargs(self, **kwargs): + def _checkargs(self, kwargs): t, n = kwargs["t"], kwargs["n"] if t <= 0: msg = f"Cannot drive with {t=}." @@ -66,6 +66,7 @@ def _checkargs(self, **kwargs): if n <= 0: msg = f"Cannot drive with {n=}." raise ValueError(msg) + return kwargs def _check_system(self, system): """Checks the system has dynamics in it"""