Skip to content

Commit

Permalink
add test for reduce formula
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Jan 25, 2025
1 parent 39a761d commit 7e895c5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/core/test_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pytest import approx

from pymatgen.core import Composition, DummySpecies, Element, Species
from pymatgen.core.composition import ChemicalPotential, CompositionError
from pymatgen.core.composition import ChemicalPotential, CompositionError, reduce_formula
from pymatgen.util.testing import PymatgenTest


Expand Down Expand Up @@ -860,6 +860,12 @@ def test_isotopes(self):
assert "Deuterium" in [elem.long_name for elem in composition.elements]


def test_reduce_formula():
assert reduce_formula({"Li": 2, "Mn": 4, "O": 8}) == ("LiMn2O4", 2)
assert reduce_formula({"Li": 4, "O": 4}) == ("LiO", 4)
assert reduce_formula({"Zn": 2, "O": 2, "H": 2}) == ("ZnHO", 2)


def test_composition_error():
error = CompositionError("Composition error")
assert isinstance(error, CompositionError)
Expand Down

0 comments on commit 7e895c5

Please sign in to comment.