26 lines
727 B
Python
26 lines
727 B
Python
import numpy
|
|
import numpy.testing
|
|
|
|
import pathfinder.model as model
|
|
|
|
|
|
def test_dot():
|
|
dot = model.Dot(0.235, (1, 2, 3))
|
|
assert dot.v == 0.235
|
|
numpy.testing.assert_array_equal(dot.r, (1, 2, 3), "These arrays should have been equal!")
|
|
|
|
|
|
def test_dot_v_from_dipole():
|
|
# for a dot located at (1, 2, 3)
|
|
dot = model.Dot(50, (1, 2, 3))
|
|
|
|
# and dipole located at (4, 7, 11) with p=(8, 9, 10)
|
|
pt = numpy.array((8, 9, 10, 4, 7, 11))
|
|
|
|
# V should be -0.153584
|
|
target = -0.1535844174880402
|
|
cost = -50.1535844174880402
|
|
|
|
numpy.testing.assert_allclose(dot.v_for_point(pt), target, err_msg="v from dipole at a dot was incorrect!")
|
|
numpy.testing.assert_allclose(dot.cost(pt), cost, err_msg="cost from dipole at a dot was incorrect!")
|