Adds better test for static dipole as well as calculating dot measurements
All checks were successful
gitea-physics/pathfinder/pipeline/head This commit looks good
All checks were successful
gitea-physics/pathfinder/pipeline/head This commit looks good
This commit is contained in:
23
tests/model/test_staticdipole.py
Normal file
23
tests/model/test_staticdipole.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import numpy
|
||||
import pathfinder.model as model
|
||||
|
||||
|
||||
def test_static_dipole():
|
||||
d1 = model.StaticDipole((1, 2, 3), (4, 5, 6))
|
||||
d2 = model.StaticDipole((4, 5, 6), (1, 2, 3))
|
||||
dipoles = model.StaticDipoleArrangement([d1, d2])
|
||||
|
||||
dot_position1 = (-1, -1, -1)
|
||||
expected_v1 = -0.3338923121348659
|
||||
|
||||
numpy.testing.assert_allclose(dipoles.get_dot_measurement(dot_position1).v, expected_v1, err_msg="Voltage at dot isn't as expected.")
|
||||
numpy.testing.assert_allclose(dipoles.get_dot_measurement(dot_position1).r, dot_position1, err_msg="Dot isn't where expected.")
|
||||
|
||||
# test multiple dots
|
||||
dot_position2 = (-1, -1, -5)
|
||||
expected_v2 = -0.1254445237566694
|
||||
|
||||
both_measurements = dipoles.get_dot_measurements([dot_position1, dot_position2])
|
||||
measured_voltages = numpy.sort([m.v for m in both_measurements])
|
||||
expected_measured_voltages = numpy.sort([expected_v1, expected_v2])
|
||||
numpy.testing.assert_allclose(measured_voltages, expected_measured_voltages, err_msg="Didn't get the measured voltages expected")
|
||||
Reference in New Issue
Block a user