openkim / kliff

KIM-based Learning-Integrated Fitting Framework for interatomic potentials.
https://kliff.readthedocs.io
GNU Lesser General Public License v2.1
34 stars 20 forks source link

Fix bug if the weight needs configuration's identifier #64

Closed yonatank93 closed 2 years ago

yonatank93 commented 2 years ago

This bug occurs when the weight value depends on the configuration's identifier. For example, we might want to weigh the configurations with cracks. The documentation shows an example on how this can be done, which uses the identifier to tell the function whether the configuration has cracks.

Previously, I didn't test this thoroughly and apparently we will get an error if we apply this example, since the identifier is defined after weight.compute_weight() is called.

I pretty much just swapped the order: now we call weight.compute_weight() after the identifier is defined.

mjwen commented 2 years ago

Thanks @yonatank93, looks good!