Skip to content

Commit

Permalink
Merge pull request #69 from ubermag/test_valid
Browse files Browse the repository at this point in the history
test check for validity of the norm
  • Loading branch information
samjrholt authored Jun 3, 2024
2 parents 4938524 + 91451dd commit 443eb2d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion micromagneticdata/abstract_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def m0(self):
Field(...)
"""
return df.Field.from_file(self._m0_path)
field = df.Field.from_file(self._m0_path)
field.valid = "norm"
return field

@property
@abc.abstractmethod
Expand Down
21 changes: 21 additions & 0 deletions micromagneticdata/tests/test_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ def test_mx3(self):
assert isinstance(drive.calculator_script, str)
assert "tableadd" in drive.calculator_script

def test_valid(self):
dirname = os.path.join(os.path.dirname(__file__), "test_sample")
name = "hysteresis"
data = md.Data(name=name, dirname=dirname)
m0_field = data[0].m0
test_points = [
m0_field.mesh.point2index(m0_field.mesh.region.pmin),
m0_field.mesh.point2index(m0_field.mesh.region.center),
m0_field.mesh.point2index(m0_field.mesh.region.pmax),
]
expected_validity = [False, True, False]
for point, expected in zip(test_points, expected_validity):
actual_valid = m0_field.valid[point]
assert actual_valid == expected

drive = data[0]
for d in drive:
for point, expected in zip(test_points, expected_validity):
actual_valid = d.valid[point]
assert actual_valid == expected

def test_m0(self):
for drive in self.data:
assert isinstance(drive.m0, df.Field)
Expand Down

0 comments on commit 443eb2d

Please sign in to comment.