From 6269071fe35a358d81ef3daedf8752c9cc5e559c Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sat, 30 Nov 2024 16:29:47 +0800 Subject: [PATCH] clean up docstring --- src/pymatgen/core/composition.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pymatgen/core/composition.py b/src/pymatgen/core/composition.py index d269c247ff9..03fac2a7412 100644 --- a/src/pymatgen/core/composition.py +++ b/src/pymatgen/core/composition.py @@ -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 @@ -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,