2 Commits

Author SHA1 Message Date
0e3eddebcc Fixes linting issue and makes html by default
All checks were successful
gitea-physics/pathfinder/pipeline/head This commit looks good
2021-08-29 15:01:54 -05:00
d31fbb55eb Improves some test stuff. 2021-08-29 14:58:52 -05:00
3 changed files with 24 additions and 1 deletions

View File

@@ -22,7 +22,7 @@ build-backend = "poetry.masonry.api"
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--junitxml pytest.xml --cov pathfinder --cov-report=xml:coverage.xml --cov-fail-under=90"
addopts = "--junitxml pytest.xml --cov pathfinder --cov-report=xml:coverage.xml --cov-fail-under=90 --cov-report=html"
junit_family = "xunit1"
[tool.mypy]

View File

@@ -14,6 +14,27 @@ def test_dotdipolemodel_m():
assert mod.m == 2
def test_dotdipolemodel_cost():
mod = model.DotDipoleModel([model.DotMeasurement(1, (0, 0, 1)), model.DotMeasurement(2, (1, 0, 0))], 1)
costs = mod.costs()
jac = mod.jac()
pt_to_test = numpy.array((1, 2, 3, 4, 5, 6))
expected_cost = [-1.05408565512728256, -2.05293155269909457]
expected_jacobian = [
[
-0.007460090362383803, -0.009325112952979752, -0.009325112952979752,
0.007968732887091788, 0.00856214916591777, 0.006697126575321822
], [
-0.00512240832571883, -0.008537347209531383, -0.01024481665143766,
0.005098015905120168, 0.007927536694564856, 0.008488562368334061
]
]
numpy.testing.assert_allclose(costs(pt_to_test), expected_cost, err_msg="Costs aren't as expected.")
numpy.testing.assert_allclose(jac(pt_to_test), expected_jacobian, err_msg="Jacobian aren't as expected.")
def print_result(msg, result):
print(msg)
print(f"\tResult: {result.x}")

View File

@@ -1,5 +1,7 @@
from pathfinder import __version__
import pathfinder
def test_version():
assert __version__ == '0.0.1'
assert pathfinder.get_version() == __version__