[tests] refactor tests
This commit is contained in:
parent
267d161769
commit
8cdcd08ba0
25 changed files with 649 additions and 616 deletions
|
|
@ -72,3 +72,29 @@ def test_far_to_nearfield_uses_default_and_scalar_padding_shapes() -> None:
|
|||
assert default_result['H'][0].shape == (8, 8)
|
||||
assert scalar_result['E'][0].shape == (4, 4)
|
||||
assert scalar_result['H'][0].shape == (4, 4)
|
||||
|
||||
|
||||
def test_farfield_roundtrip_supports_rectangular_arrays() -> None:
|
||||
e_near = [numpy.zeros((4, 8), dtype=complex), numpy.zeros((4, 8), dtype=complex)]
|
||||
h_near = [numpy.zeros((4, 8), dtype=complex), numpy.zeros((4, 8), dtype=complex)]
|
||||
e_near[0][1, 3] = 1.0 + 0.25j
|
||||
h_near[1][2, 5] = -0.5j
|
||||
|
||||
ff = farfield.near_to_farfield(e_near, h_near, dx=0.2, dy=0.3, padded_size=(4, 8))
|
||||
restored = farfield.far_to_nearfield(
|
||||
[field.copy() for field in ff['E']],
|
||||
[field.copy() for field in ff['H']],
|
||||
ff['dkx'],
|
||||
ff['dky'],
|
||||
padded_size=(4, 8),
|
||||
)
|
||||
|
||||
assert isinstance(ff['dkx'], float)
|
||||
assert isinstance(ff['dky'], float)
|
||||
assert ff['E'][0].shape == (4, 8)
|
||||
assert restored['E'][0].shape == (4, 8)
|
||||
assert restored['H'][0].shape == (4, 8)
|
||||
assert restored['dx'] == pytest.approx(0.2)
|
||||
assert restored['dy'] == pytest.approx(0.3)
|
||||
assert numpy.isfinite(restored['E'][0]).all()
|
||||
assert numpy.isfinite(restored['H'][0]).all()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue