@@ -121,16 +121,14 @@ def correct_entry(self, entry):
121121 """
122122 new_corr = self .get_correction (entry )
123123 old_std_dev = entry .correction_uncertainty
124- if np .isnan (old_std_dev ):
125- old_std_dev = 0
126- old_corr = ufloat (entry .correction , old_std_dev )
124+ old_corr = ufloat (entry .correction , 0 if np .isnan (old_std_dev ) else old_std_dev )
127125 updated_corr = new_corr + old_corr
128126
129127 # if there are no error values available for the corrections applied,
130128 # set correction uncertainty to not a number
131- uncertainty = np . nan if updated_corr . nominal_value != 0 and updated_corr . std_dev == 0 else updated_corr . std_dev
132-
133- entry . energy_adjustments . append ( ConstantEnergyAdjustment ( updated_corr . nominal_value , uncertainty ) )
129+ entry . energy_adjustments . append (
130+ ConstantEnergyAdjustment ( updated_corr . nominal_value , updated_corr . std_dev or np . nan )
131+ )
134132
135133 return entry
136134
@@ -195,7 +193,7 @@ def get_correction(self, entry: AnyComputedEntry) -> ufloat:
195193 ufloat: 0.0 +/- 0.0 (from uncertainties package)
196194 """
197195 if SETTINGS .get ("PMG_POTCAR_CHECKS" ) is False or not self .check_potcar :
198- return ufloat (0.0 , 0.0 )
196+ return ufloat (0.0 , np . nan )
199197
200198 potcar_spec = entry .parameters .get ("potcar_spec" )
201199 if self .check_hash :
@@ -211,7 +209,7 @@ def get_correction(self, entry: AnyComputedEntry) -> ufloat:
211209 expected_psp = {self .valid_potcars .get (el .symbol ) for el in entry .elements }
212210 if expected_psp != psp_settings :
213211 raise CompatibilityError (f"Incompatible POTCAR { psp_settings } , expected { expected_psp } " )
214- return ufloat (0.0 , 0.0 )
212+ return ufloat (0.0 , np . nan )
215213
216214
217215@cached_class
@@ -249,6 +247,8 @@ def get_correction(self, entry: ComputedEntry | ComputedStructureEntry) -> ufloa
249247 if rform in self .cpd_energies :
250248 correction += self .cpd_energies [rform ] * comp .num_atoms - entry .uncorrected_energy
251249
250+ if correction .std_dev == 0 :
251+ correction = ufloat (correction .nominal_value , np .nan ) # set std_dev to nan if no uncertainty
252252 return correction
253253
254254
@@ -286,7 +286,7 @@ def get_correction(self, entry: ComputedEntry | ComputedStructureEntry) -> ufloa
286286 """
287287 comp = entry .composition
288288 if len (comp ) == 1 : # Skip element entry
289- return ufloat (0.0 , 0.0 )
289+ return ufloat (0.0 , np . nan )
290290
291291 correction = ufloat (0.0 , 0.0 )
292292
@@ -345,6 +345,8 @@ def get_correction(self, entry: ComputedEntry | ComputedStructureEntry) -> ufloa
345345 else :
346346 correction += self .oxide_correction ["oxide" ] * comp ["O" ]
347347
348+ if correction .std_dev == 0 :
349+ correction = ufloat (correction .nominal_value , np .nan ) # set std_dev to nan if no uncertainty
348350 return correction
349351
350352
@@ -432,6 +434,8 @@ def get_correction(self, entry: ComputedEntry | ComputedStructureEntry) -> ufloa
432434 correction += ufloat (- 1 * MU_H2O * nH2O , 0.0 )
433435 # correction += 0.5 * 2.46 * nH2O # this is the old way this correction was calculated
434436
437+ if correction .std_dev == 0 :
438+ correction = ufloat (correction .nominal_value , np .nan ) # set std_dev to nan if no uncertainty
435439 return correction
436440
437441
@@ -537,6 +541,8 @@ def get_correction(self, entry: ComputedEntry | ComputedStructureEntry) -> ufloa
537541 if sym in u_corr :
538542 correction += ufloat (u_corr [sym ], u_errors [sym ]) * comp [el ]
539543
544+ if correction .std_dev == 0 :
545+ correction = ufloat (correction .nominal_value , np .nan ) # set std_dev to nan if no uncertainty
540546 return correction
541547
542548
@@ -1076,7 +1082,7 @@ def get_adjustments(self, entry: AnyComputedEntry) -> list[CompositionEnergyAdju
10761082 )
10771083
10781084 # check the POTCAR symbols
1079- # this should return ufloat(0, 0 ) or raise a CompatibilityError or ValueError
1085+ # this should return ufloat(0, np.nan ) or raise a CompatibilityError or ValueError
10801086 if entry .parameters .get ("software" , "vasp" ) == "vasp" :
10811087 pc = PotcarCorrection (
10821088 MPRelaxSet ,
0 commit comments