Skip to content

Commit 851f6d5

Browse files
committed
fix(types): resolve Pylance optional access errors and tighten typing within forces.py
1 parent 260df88 commit 851f6d5

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

CodeEntropy/levels/forces.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,21 +266,25 @@ def _displacements_relative_to_center(
266266
) -> np.ndarray:
267267
"""Compute displacement vectors from center to positions.
268268
269-
This method delegates displacement computation to axes_manager.get_vector,
269+
This method delegates displacement computation to ``axes_manager.get_vector``,
270270
which is expected to handle periodic boundary conditions if applicable.
271271
272272
Args:
273273
center: Reference center position of shape (3,).
274274
positions: Array of positions of shape (N, 3).
275-
axes_manager: Object providing get_vector(center, positions, box).
276-
box: Periodic box passed through to axes_manager.get_vector.
275+
axes_manager: Object providing ``get_vector(center, positions, box)``.
276+
box: Periodic box passed through to ``axes_manager.get_vector``.
277277
278278
Returns:
279279
Displacement vectors of shape (N, 3).
280280
281281
Raises:
282-
AttributeError: If axes_manager does not provide get_vector.
282+
ValueError: If ``axes_manager`` is not provided.
283+
AttributeError: If ``axes_manager`` does not provide ``get_vector``.
283284
"""
285+
if axes_manager is None:
286+
raise ValueError("axes_manager must be provided for torque computation.")
287+
284288
return axes_manager.get_vector(center, positions, box)
285289

286290
@staticmethod

0 commit comments

Comments
 (0)