Skip to content

Commit

Permalink
add bad test
Browse files Browse the repository at this point in the history
  • Loading branch information
OrtnerMichael committed May 7, 2024
1 parent b6c7a20 commit 5374617
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Empty file added tests/__init__.py
Empty file.
42 changes: 42 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
import numpy as np
import magpylib as magpy
import magpylib_material_response
from magpylib_material_response.demag import apply_demag
from magpylib_material_response.meshing import mesh_Cuboid


def test_version():
assert isinstance(magpylib_material_response.__version__, str)


def test_susceptibility_inputs():
"""
test if different xi inputs give the same result
"""

zone = magpy.magnet.Cuboid(
dimension=(1,1,1),
polarization=(0,0,1),
)
mesh = mesh_Cuboid(zone, (2,2,2))

dm1 = apply_demag(mesh, susceptibility=4)
dm2 = apply_demag(mesh, susceptibility=(4,4,4))
dm3 = apply_demag(mesh, susceptibility=[4]*8)
dm4 = apply_demag(mesh, susceptibility=[(4,4,4)]*8)

zone = magpy.magnet.Cuboid(
dimension=(1,1,1),
polarization=(0,0,1),
)
zone.susceptibility = 4
mesh = mesh_Cuboid(zone, (2,2,2))
dm5 = apply_demag(mesh)

zone = magpy.magnet.Cuboid(
dimension=(1,1,1),
polarization=(0,0,1),
)
zone.susceptibility = (4,4,4)
mesh = mesh_Cuboid(zone, (2,2,2))
dm6 = apply_demag(mesh)

b1 = dm1.getB((1,2,3))
for dm in [dm2,dm3,dm4,dm5,dm6]:
bb = dm.getB((1,2,3))
np.testing.assert_allclose(b1,bb)

0 comments on commit 5374617

Please sign in to comment.