You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From running our doped tests with the latest pymatgen release, we get many of these warnings (which breaks tests):
Using UFloat objects with std_dev==0 may give unexpected results.
From setting the warning level to error, the traceback shows:
File ~/Packages/doped/doped/core.py:1428, in DefectEntry.sc_entry_energy(self)
1425 return self._sc_entry_energy
1427 self._sc_entry_hash = hash(self.sc_entry)
-> 1428 self._sc_entry_energy = self.sc_entry.energy
1430 return self._sc_entry_energy
File ~/Packages/pymatgen/src/pymatgen/entries/computed_entries.py:350, in ComputedEntry.energy(self)
347 @property
348 def energy(self) -> float:
349 """The *corrected* energy of the entry."""
--> 350 return self.uncorrected_energy + self.correction
File ~/Packages/pymatgen/src/pymatgen/entries/computed_entries.py:367, in ComputedEntry.correction(self)
362 """
363 Returns:
364 float: the total energy correction / adjustment applied to the entry in eV.
365 """
366 # adds to ufloat(0.0, 0.0) to ensure that no corrections still result in ufloat object
--> 367 corr = ufloat(0.0, 0.0) + sum(ufloat(ea.value, ea.uncertainty) for ea in self.energy_adjustments)
368 return corr.nominal_value
File ~/miniconda3/lib/python3.10/site-packages/uncertainties/core.py:1024, in ufloat(nominal_value, std_dev, tag)
992 """
993 Create an uncertainties Variable
994
(...)
1021 and `tag` which match the input values.
1022 """
1023 if std_dev == 0:
-> 1024 warn("Using UFloat objects with std_dev==0 may give unexpected results.")
1025 return Variable(nominal_value, std_dev, tag=tag)
UserWarning: Using UFloat objects with std_dev==0 may give unexpected results.
I think this is due to a recent update in uncertainties, which now includes this warning, which occurs when there are no energy adjustments with uncertainties in ComputedEntry.energy_adjustments. Some discussion here: lmfit/lmfit-py#999
Expected Behavior
Not totally sure, but it seems like that warning is there to stay, so might make sense to catch/handle it here somehow?
Only use ufloat when there is an energy adjustment with non-zero uncertainty, otherwise just normal floats for correction values?
Python version
Python 3.10-3.12
Pymatgen version
2025.5.2
Operating system version
No response
Current behavior
From running our
doped
tests with the latestpymatgen
release, we get many of these warnings (which breaks tests):From setting the warning level to error, the traceback shows:
I think this is due to a recent update in
uncertainties
, which now includes this warning, which occurs when there are no energy adjustments with uncertainties inComputedEntry.energy_adjustments
. Some discussion here: lmfit/lmfit-py#999Expected Behavior
Not totally sure, but it seems like that warning is there to stay, so might make sense to catch/handle it here somehow?
Only use
ufloat
when there is an energy adjustment with non-zero uncertainty, otherwise just normal floats for correction values?Minimal example
Relevant files to reproduce this bug
No response
The text was updated successfully, but these errors were encountered: