tantri/tests/dipoles/test_dipoles.py
Deepak Mallubhotla 968ab1877c
All checks were successful
gitea-physics/tantri/pipeline/head This commit looks good
tests: fixes failing tests and updates justfile and readme to discuss running stuff
2024-04-20 14:12:35 -05:00

43 lines
899 B
Python
Executable File

from tantri.dipoles import Dipole, DipoleTimeSeries, DotPosition, DipoleMeasurementType
import numpy
def test_dipoles_1(snapshot):
rng = numpy.random.default_rng(1234)
dots = [DotPosition(numpy.array([0, 0, 0]), "dot1")]
d1 = Dipole(
numpy.array([0, 0, 10]),
numpy.array([5, 3, 2]),
15,
dots,
DipoleMeasurementType.ELECTRIC_POTENTIAL,
)
d2 = Dipole(
numpy.array([0, 0, 10]),
numpy.array([-2, 3, 2]),
0.1,
dots,
DipoleMeasurementType.ELECTRIC_POTENTIAL,
)
d3 = Dipole(
numpy.array([0, 0, 10]),
numpy.array([2, 1, 2]),
6,
dots,
DipoleMeasurementType.ELECTRIC_POTENTIAL,
)
d4 = Dipole(
numpy.array([0, 0, 10]),
numpy.array([-5, -5, 2]),
50,
dots,
DipoleMeasurementType.ELECTRIC_POTENTIAL,
)
ts_gen = DipoleTimeSeries([d1, d2, d3, d4], 0.01, rng_to_use=rng)
time_series = [ts_gen.transition() for i in range(50)]
assert time_series == snapshot