Skip to content

Conversation

DanielYang59
Copy link
Contributor

@DanielYang59 DanielYang59 commented May 31, 2025

Summary

  • Avoid == or != for possible float comparison

  • Fix uncertainty as int for EnergyAdjustment cannot generate repr:

    from pymatgen.entries.computed_entries import EnergyAdjustment
    
    print(EnergyAdjustment(10, uncertainty=0))

    Gives:

    Traceback (most recent call last):
      File "/Users/yang/developer/pymatgen/test_json.py", line 25, in <module>
        print(EnergyAdjustment(10, uncertainty=0))
      File "/Users/yang/developer/pymatgen/src/pymatgen/entries/computed_entries.py", line 108, in __repr__
        return f"{type(self).__name__}({name=}, {value=:.3}, {uncertainty=:.3}, {description=}, {generated_by=})"
                                                             ^^^^^^^^^^^^^^^^^
    ValueError: Precision not allowed in integer format specifier
    

@DanielYang59 DanielYang59 marked this pull request as ready for review May 31, 2025 11:08
@shyuep shyuep merged commit b8dee52 into materialsproject:master May 31, 2025
43 checks passed
@DanielYang59 DanielYang59 deleted the fix-ene-adj-repr branch May 31, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants