Skip to content

Commit

Permalink
Merge pull request #151 from ubermag/check_system
Browse files Browse the repository at this point in the history
checks for system dynamic and system energy is added
  • Loading branch information
samjrholt authored Mar 4, 2024
2 parents 41d36ac + 9249157 commit 665d99f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions oommfc/drivers/hysteresisdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def _checkargs(self, **kwargs):
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):
return "B_hysteresis"
5 changes: 5 additions & 0 deletions oommfc/drivers/mindriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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 RuntimeError("System's energy is not defined")

@property
def _x(self):
return "iteration"
7 changes: 7 additions & 0 deletions oommfc/drivers/timedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ def _checkargs(self, **kwargs):
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 RuntimeError("System's dynamics is not defined")
if len(system.energy) == 0:
raise RuntimeError("System's energy is not defined")

@property
def _x(self):
return "t"
13 changes: 13 additions & 0 deletions oommfc/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@

import oommfc as oc

not_supported_by_oommf = ["test_relax_check_for_energy", "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.")

0 comments on commit 665d99f

Please sign in to comment.