Skip to content

Commit

Permalink
Add and test doctest-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoV94 committed Jun 27, 2024
1 parent 5d2b757 commit 3d3f3be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ versionfile_build = "pytensor/_version.py"
tag_prefix = "rel-"

[tool.pytest]
addopts = "--durations=50"
addopts = "--durations=50 --doctest-modules"
testpaths = "tests/"

[tool.ruff]
Expand Down
5 changes: 3 additions & 2 deletions pytensor/gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2086,13 +2086,13 @@ def hessian_vector_product(cost, wrt, p, **grad_kwargs):
from pytensor import function
from pytensor.tensor import vector
from pytensor.gradient import jacobian, hessian_vector_product
from pytensor.gradient import grad, hessian_vector_product
x = vector('x')
p = vector('p')
rosen = (100 * (x[1:] - x[:-1] ** 2) ** 2 + (1 - x[:-1]) ** 2).sum()
rosen_jac = jacobian(rosen, x)
rosen_jac = grad(rosen, x)
rosen_hessp = hessian_vector_product(rosen, x, p)
rosen_fn = function([x], rosen)
Expand All @@ -2107,6 +2107,7 @@ def hessian_vector_product(cost, wrt, p, **grad_kwargs):
hessp=rosen_hessp_fn,
options={"xtol": 1e-8},
)
assert 0
assert res.success
np.testing.assert_allclose(res.x, np.ones_like(x0))
Expand Down

0 comments on commit 3d3f3be

Please sign in to comment.