Skip to content

Commit

Permalink
Add doctest and fix issues in example
Browse files Browse the repository at this point in the history
  • Loading branch information
PicoCentauri committed Dec 17, 2024
1 parent 650f47c commit 0a9410e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions python/vesin-torch/vesin/torch/metatensor/_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,19 @@ def __init__(self, options: NeighborListOptions, length_unit: str):
... types=torch.tensor([8, 1, 1]),
... pbc=torch.ones(3, dtype=bool),
... )
>>> options = NeighborListOptions(cutoff=4.0, full_list=True)
>>> options = NeighborListOptions(cutoff=4.0, full_list=True, strict=False)
>>> calculator = NeighborList(options, length_unit="Angstrom")
>>> neighbors = calculator.compute(system)
>>> neighbors
TensorBlock
samples (54): ['first_atom', 'second_atom', 'cell_shift_a', 'cell_shift_b',
... 'cell_shift_c']
samples (18): ['first_atom', 'second_atom', 'cell_shift_a', 'cell_shift_b', 'cell_shift_c']
components (3): ['xyz']
properties (1): ['distance']
gradients: None
>>> # The returned TensorBlock can then be registered with the system
<BLANKLINE>
The returned TensorBlock can then be registered with the system
>>> system.add_neighbor_list(options, neighbors)
"""

Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ deps =
changedir = python/vesin
commands =
pytest {posargs}
pytest --doctest-modules --pyargs vesin

[testenv:torch-tests]
passenv = *
description = Run the tests of the vesin-torch Python package
deps =
pytest
torch
metatensor-torch >=0.6,<0.7
metatensor-torch <0.7,>=0.6
numpy

cmake
Expand All @@ -54,6 +55,7 @@ commands =
python {toxinidir}/scripts/pytest-dont-rewrite-torch.py

pytest {posargs}
pytest --doctest-modules --pyargs vesin.torch


[testenv:cxx-tests]
Expand Down

0 comments on commit 0a9410e

Please sign in to comment.