From 9aaeb9b833733e2cf297a00fa4bd92124472c700 Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 23 Jan 2024 21:57:15 +0100 Subject: [PATCH 1/7] checks for system dynamic and system energy is added --- oommfc/drivers/mindriver.py | 6 +++++- oommfc/drivers/timedriver.py | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/oommfc/drivers/mindriver.py b/oommfc/drivers/mindriver.py index c0aa3c8..8745f2c 100644 --- a/oommfc/drivers/mindriver.py +++ b/oommfc/drivers/mindriver.py @@ -58,7 +58,11 @@ class MinDriver(Driver): def _checkargs(self, **kwargs): pass # no kwargs should be checked - + def check_system(self, system): + """Checks the system has energy in it""" + if len(system.energy)==0: + raise AttributeError("System's energy is not defined") + @property def _x(self): return "iteration" diff --git a/oommfc/drivers/timedriver.py b/oommfc/drivers/timedriver.py index 6b4ec1d..d55f680 100644 --- a/oommfc/drivers/timedriver.py +++ b/oommfc/drivers/timedriver.py @@ -66,7 +66,13 @@ def _checkargs(self, **kwargs): if n <= 0: msg = f"Cannot drive with {n=}." raise ValueError(msg) - + def check_system(self, system): + """Checks the system has dynamics in it""" + if len(system.dynamics)==0: + raise AttributeError("System's dynamics is not defined") + if len(system.energy)==0: + raise AttributeError("System's energy is not defined") + @property def _x(self): return "t" From f5bf8f783491b50f22a2f614b323146e731f2f21 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:01:44 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- oommfc/drivers/mindriver.py | 5 +++-- oommfc/drivers/timedriver.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/oommfc/drivers/mindriver.py b/oommfc/drivers/mindriver.py index 8745f2c..3e2b21d 100644 --- a/oommfc/drivers/mindriver.py +++ b/oommfc/drivers/mindriver.py @@ -58,11 +58,12 @@ class MinDriver(Driver): def _checkargs(self, **kwargs): pass # no kwargs should be checked + def check_system(self, system): """Checks the system has energy in it""" - if len(system.energy)==0: + if len(system.energy) == 0: raise AttributeError("System's energy is not defined") - + @property def _x(self): return "iteration" diff --git a/oommfc/drivers/timedriver.py b/oommfc/drivers/timedriver.py index d55f680..f0c819a 100644 --- a/oommfc/drivers/timedriver.py +++ b/oommfc/drivers/timedriver.py @@ -66,13 +66,14 @@ def _checkargs(self, **kwargs): if n <= 0: msg = f"Cannot drive with {n=}." raise ValueError(msg) + def check_system(self, system): """Checks the system has dynamics in it""" - if len(system.dynamics)==0: + if len(system.dynamics) == 0: raise AttributeError("System's dynamics is not defined") - if len(system.energy)==0: + if len(system.energy) == 0: raise AttributeError("System's energy is not defined") - + @property def _x(self): return "t" From 38a823ada0ac0108391e094f271d428e9b530fb4 Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Wed, 24 Jan 2024 11:59:01 +0100 Subject: [PATCH 3/7] updated the name of the function to _check_system --- oommfc/drivers/mindriver.py | 2 +- oommfc/drivers/timedriver.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oommfc/drivers/mindriver.py b/oommfc/drivers/mindriver.py index 3e2b21d..fbea635 100644 --- a/oommfc/drivers/mindriver.py +++ b/oommfc/drivers/mindriver.py @@ -59,7 +59,7 @@ class MinDriver(Driver): def _checkargs(self, **kwargs): pass # no kwargs should be checked - def check_system(self, system): + def _check_system(self, system): """Checks the system has energy in it""" if len(system.energy) == 0: raise AttributeError("System's energy is not defined") diff --git a/oommfc/drivers/timedriver.py b/oommfc/drivers/timedriver.py index f0c819a..3acf7e4 100644 --- a/oommfc/drivers/timedriver.py +++ b/oommfc/drivers/timedriver.py @@ -67,7 +67,7 @@ def _checkargs(self, **kwargs): msg = f"Cannot drive with {n=}." raise ValueError(msg) - def check_system(self, system): + def _check_system(self, system): """Checks the system has dynamics in it""" if len(system.dynamics) == 0: raise AttributeError("System's dynamics is not defined") From d99176ae9aeabd113ea32554b383fa3aa789ba28 Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 30 Jan 2024 13:10:16 +0100 Subject: [PATCH 4/7] Raised error value changed form Attribute to RunTime --- oommfc/drivers/hysteresisdriver.py | 5 +++++ oommfc/drivers/mindriver.py | 2 +- oommfc/drivers/timedriver.py | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/oommfc/drivers/hysteresisdriver.py b/oommfc/drivers/hysteresisdriver.py index 089c90b..17ff240 100644 --- a/oommfc/drivers/hysteresisdriver.py +++ b/oommfc/drivers/hysteresisdriver.py @@ -73,6 +73,11 @@ 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) + + def _check_system(self, system): + """Checks the system has energy in it""" + if len(system.energy) == 0: + raise RuntimeError("System's energy is not defined") @property def _x(self): diff --git a/oommfc/drivers/mindriver.py b/oommfc/drivers/mindriver.py index fbea635..413d275 100644 --- a/oommfc/drivers/mindriver.py +++ b/oommfc/drivers/mindriver.py @@ -62,7 +62,7 @@ def _checkargs(self, **kwargs): def _check_system(self, system): """Checks the system has energy in it""" if len(system.energy) == 0: - raise AttributeError("System's energy is not defined") + raise RuntimeError("System's energy is not defined") @property def _x(self): diff --git a/oommfc/drivers/timedriver.py b/oommfc/drivers/timedriver.py index 3acf7e4..328cdef 100644 --- a/oommfc/drivers/timedriver.py +++ b/oommfc/drivers/timedriver.py @@ -70,9 +70,9 @@ def _checkargs(self, **kwargs): def _check_system(self, system): """Checks the system has dynamics in it""" if len(system.dynamics) == 0: - raise AttributeError("System's dynamics is not defined") + raise RuntimeError("System's dynamics is not defined") if len(system.energy) == 0: - raise AttributeError("System's energy is not defined") + raise RuntimeError("System's energy is not defined") @property def _x(self): From 18c230f54d76c9ffd77b282928bec599eec9fa79 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:10:32 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- oommfc/drivers/hysteresisdriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oommfc/drivers/hysteresisdriver.py b/oommfc/drivers/hysteresisdriver.py index 17ff240..69a2fc5 100644 --- a/oommfc/drivers/hysteresisdriver.py +++ b/oommfc/drivers/hysteresisdriver.py @@ -73,7 +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) - + def _check_system(self, system): """Checks the system has energy in it""" if len(system.energy) == 0: From 41bd3bfc596c35508cde30f1391a2efe234afd04 Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 27 Feb 2024 18:02:23 +0100 Subject: [PATCH 6/7] Filter out unsupported tests ubermag/micromagnetictests#47 introduces additional tests for the relax driver which is not supported in oommf. --- oommfc/tests/conftest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/oommfc/tests/conftest.py b/oommfc/tests/conftest.py index bbd5033..e8f87b7 100644 --- a/oommfc/tests/conftest.py +++ b/oommfc/tests/conftest.py @@ -2,7 +2,20 @@ import oommfc as oc +not_supported_by_oommf = ["test_check_for_energy_and_dynamics", "test_relaxdriver"] + @pytest.fixture(scope="module") def calculator(): return oc + + +@pytest.fixture(autouse=True) +def skip_unsupported_or_missing(request): + requesting_test_function = ( + f"{request.cls.__name__}.{request.function.__name__}" + if request.cls + else request.function.__name__ + ) + if requesting_test_function in not_supported_by_oommf: + pytest.skip("Not supported by OOMMF.") From 10870e6e2ff20cbc9077b9601e5a7d2dc6edfacd Mon Sep 17 00:00:00 2001 From: Sam Holt <48217392+samjrholt@users.noreply.github.com> Date: Fri, 1 Mar 2024 10:51:16 +0100 Subject: [PATCH 7/7] Rename relax test --- oommfc/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oommfc/tests/conftest.py b/oommfc/tests/conftest.py index e8f87b7..d4447a3 100644 --- a/oommfc/tests/conftest.py +++ b/oommfc/tests/conftest.py @@ -2,7 +2,7 @@ import oommfc as oc -not_supported_by_oommf = ["test_check_for_energy_and_dynamics", "test_relaxdriver"] +not_supported_by_oommf = ["test_relax_check_for_energy", "test_relaxdriver"] @pytest.fixture(scope="module")