Skip to content

Commit e3a638f

Browse files
author
Ewan Wallace
committed
energies.ndim=1
1 parent 91718fd commit e3a638f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/neural_optimiser/calculators/_mmff94.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _calculate(self, batch: Data | Batch) -> tuple[torch.Tensor, torch.Tensor]:
9393
mol = self._prepare_mol(mol)
9494

9595
ff = self._build_forcefield(mol)
96-
energy = torch.tensor(ff.CalcEnergy())
96+
energy = torch.tensor([ff.CalcEnergy()])
9797
grad = (
9898
torch.Tensor(ff.CalcGrad()) * -KCAL_PER_MOL_TO_EV
9999
) # Convert to eV/Å for convergence criteria
@@ -106,4 +106,4 @@ def get_energies(self, batch: Data | Batch) -> torch.Tensor:
106106
mol = self._prepare_mol(mol)
107107

108108
ff = self._build_forcefield(mol)
109-
return torch.tensor(ff.CalcEnergy())
109+
return torch.tensor([ff.CalcEnergy()])

tests/calculators/test_mmff94.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_single_conformer_energy_and_forces_shape(batch):
4848

4949
# energy is a scalar tensor
5050
assert isinstance(energy, torch.Tensor)
51-
assert energy.ndim == 0
51+
assert energy.ndim == 1
5252

5353
# forces match [n_atoms, 3]
5454
assert isinstance(forces, torch.Tensor)

0 commit comments

Comments
 (0)