Skip to content

Commit cd6e274

Browse files
committed
Minor typing fixes.
1 parent f438df6 commit cd6e274

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/pymatgen/analysis/structure_matcher.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,16 @@ def _get_mask(self, struct1, struct2, fu, s1_supercell):
590590

591591
def fit(
592592
self,
593-
struct1: Structure,
594-
struct2: Structure,
593+
struct1: Structure | IStructure,
594+
struct2: Structure | IStructure,
595595
symmetric: bool = False,
596596
skip_structure_reduction: bool = False,
597597
) -> bool:
598598
"""Fit two structures.
599599
600600
Args:
601-
struct1 (Structure): 1st structure
602-
struct2 (Structure): 2nd structure
601+
struct1 (Structure | IStructure): 1st structure
602+
struct2 (Structure | IStructure): 2nd structure
603603
symmetric (bool): Defaults to False
604604
If True, check the equality both ways.
605605
This only impacts a small percentage of structures
@@ -984,7 +984,9 @@ def _get_reduced_istructure(
984984
return reduced
985985

986986
@classmethod
987-
def _get_reduced_structure(cls, struct: Structure, primitive_cell: bool = True, niggli: bool = True) -> Structure:
987+
def _get_reduced_structure(
988+
cls, struct: Structure | IStructure, primitive_cell: bool = True, niggli: bool = True
989+
) -> Structure:
988990
"""Helper method to find a reduced structure."""
989991
return Structure.from_sites(
990992
cls._get_reduced_istructure(SiteOrderedIStructure.from_sites(struct), primitive_cell, niggli)
@@ -1015,7 +1017,9 @@ def get_rms_anonymous(self, struct1, struct2):
10151017

10161018
return None, None
10171019

1018-
def get_best_electronegativity_anonymous_mapping(self, struct1: Structure, struct2: Structure) -> dict | None:
1020+
def get_best_electronegativity_anonymous_mapping(
1021+
self, struct1: Structure | IStructure, struct2: Structure | IStructure
1022+
) -> dict | None:
10191023
"""
10201024
Performs an anonymous fitting, which allows distinct species in one
10211025
structure to map to another. e.g. to compare if the Li2O and Na2O
@@ -1075,8 +1079,8 @@ def get_all_anonymous_mappings(self, struct1, struct2, niggli=True, include_dist
10751079

10761080
def fit_anonymous(
10771081
self,
1078-
struct1: Structure,
1079-
struct2: Structure,
1082+
struct1: Structure | IStructure,
1083+
struct2: Structure | IStructure,
10801084
niggli: bool = True,
10811085
skip_structure_reduction: bool = False,
10821086
) -> bool:

src/pymatgen/core/structure.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __init__(
156156
properties: dict | None = None,
157157
nn_distance: float = 0.0,
158158
index: int = 0,
159-
image: tuple = (0, 0, 0),
159+
image: tuple[int, int, int] = (0, 0, 0),
160160
label: str | None = None,
161161
) -> None:
162162
"""
@@ -1016,7 +1016,7 @@ def __init__(
10161016
self,
10171017
lattice: NDArray[np.float64] | Lattice,
10181018
species: Sequence[CompositionLike],
1019-
coords: Sequence[NDArray[np.float64]],
1019+
coords: Sequence[NDArray[np.float64]] | Sequence[Sequence[float]],
10201020
charge: float | None = None,
10211021
validate_proximity: bool = False,
10221022
to_unit_cell: bool = False,
@@ -1081,7 +1081,7 @@ def __init__(
10811081

10821082
site = PeriodicSite(
10831083
specie,
1084-
coords[idx],
1084+
np.array(coords[idx]),
10851085
self._lattice,
10861086
to_unit_cell,
10871087
coords_are_cartesian=coords_are_cartesian,
@@ -1580,7 +1580,7 @@ def get_space_group_info(
15801580

15811581
def matches(
15821582
self,
1583-
other: Self | Structure,
1583+
other: Structure | IStructure,
15841584
anonymous: bool = False,
15851585
**kwargs,
15861586
) -> bool:
@@ -1675,7 +1675,7 @@ def get_sites_in_sphere(
16751675
self._lattice,
16761676
properties=self[idx].properties,
16771677
nn_distance=dist,
1678-
image=img,
1678+
image=tuple(img),
16791679
index=idx,
16801680
label=self[idx].label,
16811681
)
@@ -2764,7 +2764,7 @@ def get_orderings(
27642764
self,
27652765
mode: Literal["enum", "sqs"] = "enum",
27662766
**kwargs,
2767-
) -> list[Structure]:
2767+
) -> list[Structure | IStructure]:
27682768
"""Get list of orderings for a disordered structure. If structure
27692769
does not contain disorder, the default structure is returned.
27702770

0 commit comments

Comments
 (0)