def METHOD_NAME(mat):
    """Convert string material formulas into pymatgen Compositions."""
    formula = mat["material_formula"]
    formula = re.sub(r"·\d*H2O", "", formula)
    try:
        return Composition(formula)
    except (CompositionError, ValueError):
        q = None
        for comp in mat["composition"]:
            if q is None:
                q = Composition(
                    {x: float(y) for x, y in comp["elements"].items()}
                ) * float(comp["amount"])
            else:
                q += Composition(
                    {x: float(y) for x, y in comp["elements"].items()}
                ) * float(comp["amount"])
        return q