Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checks for system dynamic and system energy is added #151

Merged
merged 8 commits into from
Mar 4, 2024
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 @@
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")

Check warning on line 80 in oommfc/drivers/hysteresisdriver.py

View check run for this annotation

Codecov / codecov/patch

oommfc/drivers/hysteresisdriver.py#L80

Added line #L80 was not covered by tests

@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 @@
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")

Check warning on line 65 in oommfc/drivers/mindriver.py

View check run for this annotation

Codecov / codecov/patch

oommfc/drivers/mindriver.py#L65

Added line #L65 was not covered by tests

@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.")
Loading