Skip to content

Commit ec4e663

Browse files
committed
Fix ruff codespell mypy
1 parent eb9062d commit ec4e663

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/pymatgen/electronic_structure/cohp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ def __init__(
980980
self._atom1 = atom1
981981
self._atom2 = atom2
982982
self._length = length
983+
# TODO switch to integer translation in LOBSTER classes
983984
self._translation = translation
984985
self._num = num
985986
self._icohp = icohp
@@ -1044,13 +1045,13 @@ def is_spin_polarized(self) -> bool:
10441045
return self._is_spin_polarized
10451046

10461047
@property
1047-
def translation(self) -> list[int, int, int]:
1048+
def translation(self) -> tuple[float, float, float]:
10481049
"""
10491050
Returns the translation vector with respect to the origin cell
10501051
as defined in LOBSTER.
10511052
10521053
Returns:
1053-
list[int, int, int]
1054+
tuple[float, float, float]
10541055
"""
10551056
return self._translation
10561057

src/pymatgen/io/lobster/lobsterenv.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __init__(
127127
filename_blist_sg2 (PathLike): Path to additional ICOOP, ICOBI data for structure graphs.
128128
id_blist_sg1 ("icoop" | "icobi"): Identity of data in filename_blist_sg1.
129129
id_blist_sg2 ("icoop" | "icobi"): Identity of data in filename_blist_sg2.
130-
backward_compatibility (bool): compatiblity with neighbor detection prior 2025 (less strict).
130+
backward_compatibility (bool): compatibility with neighbor detection prior 2025 (less strict).
131131
"""
132132
if filename_icohp is not None:
133133
self.ICOHP = Icohplist(are_coops=are_coops, are_cobis=are_cobis, filename=filename_icohp)
@@ -1065,7 +1065,7 @@ def _find_relevant_atoms_additional_condition(
10651065
site_idx: int,
10661066
icohps: dict[str, IcohpValue],
10671067
additional_condition: Literal[0, 1, 2, 3, 4, 5, 6],
1068-
) -> tuple[list[str], list[float], list[int], list[float]]:
1068+
) -> tuple[list[str], list[float], list[int], list[float], list[tuple[float, float, float]]]:
10691069
"""Find all relevant atoms that fulfill the additional condition.
10701070
10711071
Args:
@@ -1079,8 +1079,8 @@ def _find_relevant_atoms_additional_condition(
10791079
keys_from_ICOHPs: list[str] = []
10801080
lengths_from_ICOHPs: list[float] = []
10811081
neighbors_from_ICOHPs: list[int] = []
1082-
icohps_from_ICOHPs: list[IcohpValue] = []
1083-
translation_from_ICOHPs: list[list[int, int, int]] = []
1082+
icohps_from_ICOHPs: list[float] = []
1083+
translation_from_ICOHPs: list[tuple[float, float, float]] = []
10841084

10851085
for key, icohp in icohps.items():
10861086
atomnr1 = self._get_atomnumber(icohp._atom1)
@@ -1582,15 +1582,18 @@ class ICOHPNeighborsInfo(NamedTuple):
15821582
def check_ICOHPs(lengths_from_ICOHPs, selected_ICOHPs, translation, length_threshold=0.01, energy_threshold=0.1):
15831583
for i in range(len(lengths_from_ICOHPs)):
15841584
for j in range(i + 1, len(lengths_from_ICOHPs)):
1585-
if abs(lengths_from_ICOHPs[i] - lengths_from_ICOHPs[j]) < length_threshold:
1586-
if abs(selected_ICOHPs[i] - selected_ICOHPs[j]) > energy_threshold and (
1585+
if (
1586+
abs(lengths_from_ICOHPs[i] - lengths_from_ICOHPs[j]) < length_threshold
1587+
and abs(selected_ICOHPs[i] - selected_ICOHPs[j]) > energy_threshold
1588+
and (
15871589
translation[i][0] == -translation[j][0]
15881590
and translation[i][1] == -translation[j][1]
15891591
and translation[i][2] == -translation[j][2]
1590-
):
1591-
warnings.warn(
1592-
f"Lengths {lengths_from_ICOHPs[i]} and {lengths_from_ICOHPs[j]} are very close "
1593-
f"and translation exactly opposite, but corresponding ICOHPs {selected_ICOHPs[i]} "
1594-
f"and {selected_ICOHPs[j]} are not. Our neighbor detection might fail.",
1595-
stacklevel=2,
1596-
)
1592+
)
1593+
):
1594+
warnings.warn(
1595+
f"Lengths {lengths_from_ICOHPs[i]} and {lengths_from_ICOHPs[j]} are very close "
1596+
f"and translation exactly opposite, but corresponding ICOHPs {selected_ICOHPs[i]} "
1597+
f"and {selected_ICOHPs[j]} are not. Our neighbor detection might fail.",
1598+
stacklevel=2,
1599+
)

0 commit comments

Comments
 (0)