From c74f949ccdada2169fb65bb27b1dd00583747556 Mon Sep 17 00:00:00 2001 From: "Andrew S. Rosen" Date: Sat, 11 May 2024 16:25:18 -0700 Subject: [PATCH] Ensure `free_energy` property is a `float` and not `np.array(float)` The ASE `Calculator.results` attribute of `free_energy` should be formatted as a `float` but is currently formatted as a `np.array(float)`. For instance, `array(-4.0938973, dtype=float32)`. Since this is not the expected ASE type and because it is not iterable, this can cause a variety of unexpected problems. https://github.com/materialsvirtuallab/monty/issues/668 is just one example. I have ensured `free_energy` is returned as a `float` in this PR. Signed-off-by: Andrew S. Rosen --- src/matgl/ext/ase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matgl/ext/ase.py b/src/matgl/ext/ase.py index 26d0a2a6..4d90fec6 100644 --- a/src/matgl/ext/ase.py +++ b/src/matgl/ext/ase.py @@ -178,7 +178,7 @@ def calculate( calc_result = self.potential(graph, lattice, state_attr_default) self.results.update( energy=calc_result[0].detach().cpu().numpy().item(), - free_energy=calc_result[0].detach().cpu().numpy(), + free_energy=calc_result[0].detach().cpu().numpy().item(), forces=calc_result[1].detach().cpu().numpy(), ) if self.compute_stress: