Adds a lot of stuff for discretisation
This commit is contained in:
@@ -2,13 +2,13 @@ from pdme.model.fixed_z_plane_model import FixedZPlaneModel, FixedZPlaneDiscreti
|
||||
import numpy
|
||||
|
||||
|
||||
def test_fixed_z_plane_model_cost_and_jac_single():
|
||||
def test_fixed_z_plane_model_discretization():
|
||||
model = FixedZPlaneModel(4, -10, 10, -10, 10, 1)
|
||||
discretisation = FixedZPlaneDiscretisation(model, 2, 5)
|
||||
discretisation = FixedZPlaneDiscretisation(model, 2, 5, 15)
|
||||
# x: (-10, 0) and (0, 10)
|
||||
# y: (-10, -6, -2, 2, 6, 10)
|
||||
assert discretisation.cell_count == 10
|
||||
assert discretisation.x_step == 10
|
||||
assert discretisation.y_step == 4
|
||||
numpy.testing.assert_allclose(discretisation.bounds((0, 0)), ((-numpy.inf, -10, -10, -numpy.inf), (numpy.inf, 0, -6, numpy.inf)))
|
||||
numpy.testing.assert_allclose(discretisation.bounds((0, 0)), ((-15, -10, -10, -numpy.inf), (15, 0, -6, numpy.inf)))
|
||||
numpy.testing.assert_allclose(list(discretisation.all_indices()), list(numpy.ndindex((2, 5))))
|
||||
|
||||
@@ -13,7 +13,7 @@ def test_unrestricted_model_solve_basic():
|
||||
))
|
||||
dots = dipoles.get_dot_measurements(dot_inputs)
|
||||
|
||||
model = UnrestrictedModel(1)
|
||||
model = UnrestrictedModel(1, -1, 1, -1, 1, -1, 1)
|
||||
|
||||
# from the dipole, these are the unspecified variables in ((0, 0, 2), (1, 2, 4), 1)
|
||||
expected_solution = [0.2, 0, 2, 1, 2, 4, 1]
|
||||
|
||||
15
tests/model/test_unrestricted_discretization.py
Normal file
15
tests/model/test_unrestricted_discretization.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from pdme.model.unrestricted_model import UnrestrictedModel, UnrestrictedDiscretisation
|
||||
import numpy
|
||||
|
||||
|
||||
def test_unrestricted_model_discretization():
|
||||
model = UnrestrictedModel(-10, 10, -10, 10, -10, 10, 1)
|
||||
discretisation = UnrestrictedDiscretisation(model, 2, 5, 1, 15)
|
||||
# x: (-10, 0) and (0, 10)
|
||||
# y: (-10, -6, -2, 2, 6, 10)
|
||||
assert discretisation.cell_count == 10
|
||||
assert discretisation.x_step == 10
|
||||
assert discretisation.y_step == 4
|
||||
assert discretisation.z_step == 20
|
||||
numpy.testing.assert_allclose(discretisation.bounds((0, 0, 0)), ((-15, -15, -15, -10, -10, -10, -numpy.inf), (15, 15, 15, 0, -6, 10, numpy.inf)))
|
||||
numpy.testing.assert_allclose(list(discretisation.all_indices()), list(numpy.ndindex((2, 5, 1))))
|
||||
@@ -5,12 +5,12 @@ import numpy
|
||||
|
||||
|
||||
def test_unrestricted_plane_model_repr():
|
||||
model = UnrestrictedModel(6)
|
||||
assert repr(model) == "UnrestrictedModel(6)"
|
||||
model = UnrestrictedModel(1, 2, 3, 4, 5, 6, 6)
|
||||
assert repr(model) == "UnrestrictedModel(1, 2, 3, 4, 5, 6, 6)"
|
||||
|
||||
|
||||
def test_unrestricted_model_cost_and_jac_single():
|
||||
model = UnrestrictedModel(1)
|
||||
model = UnrestrictedModel(1, -1, 1, -1, 1, -1, 1)
|
||||
measured_v = 0.000191292 # from dipole with p=(0, 0, 2) at (1, 2, 4) with w = 1
|
||||
dot = DotMeasurement(measured_v, (1, 2, 0), 5)
|
||||
pt = numpy.array([0, 0, 2, 2, 2, 4, 2])
|
||||
|
||||
Reference in New Issue
Block a user