Skip to content

Commit

Permalink
clarify type of list_icohp
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Jun 13, 2024
1 parent 952e206 commit 4ee908d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions pymatgen/electronic_structure/cohp.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ def __init__(
length: float,
translation: Vector3D,
num: int,
icohp: dict[Spin, IcohpValue],
icohp: dict[Spin, float],
are_coops: bool = False,
are_cobis: bool = False,
orbitals: dict[str, dict[Literal["icohp", "orbitals"], Any]] | None = None,
Expand All @@ -952,7 +952,7 @@ def __init__(
length (float): Bond length.
translation (Vector3D): cell translation vector, e.g. (0, 0, 0).
num (int): The number of equivalent bonds.
icohp (dict): {Spin.up: IcohpValue for spin.up, Spin.down: IcohpValue for spin.down}
icohp (dict[Spin, float]): {Spin.up: ICOHP_up, Spin.down: ICOHP_down}
are_coops (bool): Whether these are COOPs.
are_cobis (bool): Whether these are COBIs.
orbitals (dict): {[str(Orbital1)-str(Orbital2)]: {
Expand Down Expand Up @@ -1070,11 +1070,11 @@ def icohpvalue_orbital(
return self._orbitals[orbitals]["icohp"][spin]

@property
def icohp(self) -> dict[Spin, IcohpValue]:
def icohp(self) -> dict[Spin, float]:
"""Dict with ICOHPs for spin up and spin down.
Returns:
dict: {Spin.up: IcohpValue for spin.up, Spin.down: IcohpValue for spin.down}.
dict[Spin, float]: {Spin.up: ICOHP_up, Spin.down: ICOHP_down}.
"""
return self._icohp

Expand Down Expand Up @@ -1120,7 +1120,7 @@ def __init__(
list_length: list[float],
list_translation: list[Vector3D],
list_num: list[int],
list_icohp: list[dict[Spin, IcohpValue]],
list_icohp: list[dict[Spin, float]],
is_spin_polarized: bool,
list_orb_icohp: list[dict[str, dict[Literal["icohp", "orbitals"], Any]]] | None = None,
are_coops: bool = False,
Expand All @@ -1134,7 +1134,7 @@ def __init__(
list_length (list[float]): Bond lengths in Angstrom.
list_translation (list[Vector3D]): Cell translation vectors.
list_num (list[int]): Numbers of equivalent bonds, usually 1 starting from LOBSTER 3.0.0.
list_icohp (list[dict]): Dicts as {Spin.up: IcohpValue for spin.up, Spin.down: IcohpValue for spin.down}.
list_icohp (list[dict]): Dicts as {Spin.up: ICOHP_up, Spin.down: ICOHP_down}.
is_spin_polarized (bool): Whether the calculation is spin polarized.
list_orb_icohp (list[dict]): Dicts as {[str(Orbital1)-str(Orbital2)]: {
"icohp": {Spin.up: IcohpValue for spin.up, Spin.down: IcohpValue for spin.down},
Expand All @@ -1157,6 +1157,8 @@ def __init__(
self._list_icohp = list_icohp
self._list_orb_icohp = list_orb_icohp

# TODO: DanielYang: self._icohplist name is misleading
# (not list), and confuses with self._list_icohp
self._icohplist: dict[str, IcohpValue] = {}
for idx, label in enumerate(list_labels):
self._icohplist[label] = IcohpValue(
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/io/lobster/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def __init__(
list_length=lens,
list_translation=translations, # type: ignore[arg-type]
list_num=nums,
list_icohp=icohps, # DEBUG: DanielYang: inconsistent type
list_icohp=icohps,
is_spin_polarized=self.is_spin_polarized,
list_orb_icohp=list_orb_icohp,
)
Expand Down

0 comments on commit 4ee908d

Please sign in to comment.