mir-group / flare

An open-source Python package for creating fast and accurate interatomic potentials.

Home Page:https://mir-group.github.io/flare

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnboundLocalError: local variable 'single_atom_energies' referenced before assignment

ThePauliPrinciple opened this issue · comments

Describe the bug
Using the development branch:
When using the flare/scripts/otf_train.py script, I get the following error UnboundLocalError: local variable 'single_atom_energies' referenced before assignment.
An else statement handling this case should probably be added here:

species_map = {flare_config.get("species")[i]: i for i in range(n_species)}
sae_dct = flare_config.get("single_atom_energies", None)
if sae_dct is not None:
assert n_species == len(
sae_dct
), "'single_atom_energies' should be the same length as 'species'"
single_atom_energies = {i: sae_dct[i] for i in range(n_species)}
sgp = SGP_Wrapper(
kernels=kernels,
descriptor_calculators=descriptors,
cutoff=cutoff,
sigma_e=flare_config.get("energy_noise"),
sigma_f=flare_config.get("forces_noise"),
sigma_s=flare_config.get("stress_noise"),
species_map=species_map,
variance_type=flare_config.get("variance_type", "local"),
single_atom_energies=single_atom_energies,
energy_training=flare_config.get("energy_training", True),
force_training=flare_config.get("force_training", True),
stress_training=flare_config.get("stress_training", True),
max_iterations=max_iterations,
opt_method=opt_algorithm,
bounds=bounds,
)

close by #327