Skip to content

Commit

Permalink
Make sure copying data in error calc doesn't break when data is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
bernstei committed Dec 3, 2024
1 parent 1dac49e commit 10898b2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions wfl/fit/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def _reshape_normalize(quant, prop, atoms, per_atom):
raise ValueError("/atom only possible in config_properties")
data = at.arrays

# grab data, make a copy so normalization doesn't affect original
ref_quant = np.asarray(data.get(ref_property_prefix + prop_use)).copy()
calc_quant = np.asarray(data.get(calc_property_prefix + prop_use)).copy()
# grab data
ref_quant = data.get(ref_property_prefix + prop_use)
calc_quant = data.get(calc_property_prefix + prop_use)
if ref_quant is None or calc_quant is None:
# warn if data is missing by reporting summary at the very end
if prop not in missed_prop_counter:
Expand All @@ -165,6 +165,10 @@ def _reshape_normalize(quant, prop, atoms, per_atom):

continue

# make a copy so normalization doesn't affect original
ref_quant = np.asarray(ref_quant).copy()
calc_quant = np.asarray(calc_quant).copy()

if virial_from_stress:
# ref quant was actually stress, automatically convert
ref_quant *= -at.get_volume()
Expand Down

0 comments on commit 10898b2

Please sign in to comment.