Skip to content

Commit

Permalink
clean up docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Nov 30, 2024
1 parent 06abd50 commit 6269071
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/pymatgen/core/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

if TYPE_CHECKING:
from collections.abc import Generator, Iterator
from typing import Any, ClassVar
from typing import Any, ClassVar, Literal

from typing_extensions import Self

Expand Down Expand Up @@ -774,17 +774,25 @@ def to_reduced_dict(self) -> dict[str, float]:
def to_weight_dict(self) -> dict[str, float]:
"""
Returns:
dict[str, float] with weight fraction of each component {"Ti": 0.90, "V": 0.06, "Al": 0.04}.
dict[str, float]: weight fractions of each component, e.g. {"Ti": 0.90, "V": 0.06, "Al": 0.04}.
"""
return {str(el): self.get_wt_fraction(el) for el in self.elements}

@property
def to_data_dict(self) -> dict[str, Any]:
def to_data_dict(
self,
) -> dict[
Literal["reduced_cell_composition", "unit_cell_composition", "reduced_cell_formula", "elements", "nelements"],
Any,
]:
"""
Returns:
A dict with many keys and values relating to Composition/Formula,
including reduced_cell_composition, unit_cell_composition,
reduced_cell_formula, elements and nelements.
dict with the following keys:
- reduced_cell_composition
- unit_cell_composition
- reduced_cell_formula
- elements
- nelements.
"""
return {
"reduced_cell_composition": self.reduced_composition,
Expand Down

0 comments on commit 6269071

Please sign in to comment.