@@ -1014,9 +1014,9 @@ class IStructure(SiteCollection, MSONable):
1014
1014
1015
1015
def __init__ (
1016
1016
self ,
1017
- lattice : NDArray [ np . float64 ] | Lattice ,
1017
+ lattice : ArrayLike | Lattice ,
1018
1018
species : Sequence [CompositionLike ],
1019
- coords : Sequence [NDArray [ np . float64 ]] | Sequence [ Sequence [ float ] ],
1019
+ coords : Sequence [ArrayLike ],
1020
1020
charge : float | None = None ,
1021
1021
validate_proximity : bool = False ,
1022
1022
to_unit_cell : bool = False ,
@@ -1276,9 +1276,9 @@ def from_sites(
1276
1276
def from_spacegroup (
1277
1277
cls ,
1278
1278
sg : str | int ,
1279
- lattice : list | np . ndarray | Lattice ,
1279
+ lattice : ArrayLike | Lattice ,
1280
1280
species : Sequence [str | Element | Species | DummySpecies | Composition ],
1281
- coords : Sequence [Sequence [ float ] ],
1281
+ coords : Sequence [ArrayLike ],
1282
1282
site_properties : dict [str , Sequence ] | None = None ,
1283
1283
coords_are_cartesian : bool = False ,
1284
1284
tol : float = 1e-5 ,
@@ -1346,7 +1346,9 @@ def from_spacegroup(
1346
1346
raise ValueError (f"Supplied species and coords lengths ({ len (species )} vs { len (coords )} ) are different!" )
1347
1347
1348
1348
frac_coords = (
1349
- lattice .get_fractional_coords (coords ) if coords_are_cartesian else np .array (coords , dtype = np .float64 )
1349
+ lattice .get_fractional_coords (np .asarray (coords , dtype = np .float64 ))
1350
+ if coords_are_cartesian
1351
+ else np .asarray (coords , dtype = np .float64 )
1350
1352
)
1351
1353
1352
1354
props = {} if site_properties is None else site_properties
@@ -1376,7 +1378,7 @@ def from_spacegroup(
1376
1378
def from_magnetic_spacegroup (
1377
1379
cls ,
1378
1380
msg : str | MagneticSpaceGroup ,
1379
- lattice : list | np . ndarray | Lattice ,
1381
+ lattice : ArrayLike | Lattice ,
1380
1382
species : Sequence [str | Element | Species | DummySpecies | Composition ],
1381
1383
coords : Sequence [Sequence [float ]],
1382
1384
site_properties : dict [str , Sequence ],
@@ -1521,7 +1523,7 @@ def charge(self) -> float:
1521
1523
return self ._charge
1522
1524
1523
1525
@property
1524
- def distance_matrix (self ) -> np .ndarray :
1526
+ def distance_matrix (self ) -> NDArray [ np .float64 ] :
1525
1527
"""The distance matrix between all sites in the structure. For
1526
1528
periodic structures, this should return the nearest image distance.
1527
1529
"""
@@ -2798,7 +2800,7 @@ def get_orderings(
2798
2800
disordered_sites = [site for site in self if not site .is_ordered ]
2799
2801
subset_structure = Structure .from_sites (disordered_sites )
2800
2802
dist_matrix = subset_structure .distance_matrix
2801
- dists = sorted (set (dist_matrix .ravel ()))
2803
+ dists = sorted (set (dist_matrix .ravel ())) # type:ignore[type-var]
2802
2804
unique_dists = []
2803
2805
for idx in range (1 , len (dists )):
2804
2806
if dists [idx ] - dists [idx - 1 ] > 0.1 :
@@ -3442,7 +3444,7 @@ class IMolecule(SiteCollection, MSONable):
3442
3444
def __init__ (
3443
3445
self ,
3444
3446
species : Sequence [CompositionLike ],
3445
- coords : Sequence [np . ndarray ] | np . ndarray ,
3447
+ coords : Sequence [ArrayLike ] | ArrayLike ,
3446
3448
charge : float = 0.0 ,
3447
3449
spin_multiplicity : int | None = None ,
3448
3450
validate_proximity : bool = False ,
@@ -3480,10 +3482,10 @@ def __init__(
3480
3482
properties (dict): dictionary containing properties associated
3481
3483
with the whole molecule.
3482
3484
"""
3483
- if len (species ) != len (coords ):
3485
+ if len (species ) != len (coords ): # type:ignore[arg-type]
3484
3486
raise StructureError (
3485
- f"len(species) != len(coords) ({ len (species )} != { len (coords )} ). List of atomic species must "
3486
- " have same length as list of fractional coordinates."
3487
+ f"len(species) != len(coords) ({ len (species )} != { len (coords )} ). " # type:ignore[arg-type]
3488
+ f"List of atomic species must have same length as list of fractional coordinates."
3487
3489
)
3488
3490
3489
3491
self ._charge_spin_check = charge_spin_check
@@ -3494,7 +3496,7 @@ def __init__(
3494
3496
if site_properties :
3495
3497
prop = {k : v [idx ] for k , v in site_properties .items ()}
3496
3498
label = labels [idx ] if labels else None
3497
- sites .append (Site (species [idx ], coords [idx ], properties = prop , label = label ))
3499
+ sites .append (Site (species [idx ], coords [idx ], properties = prop , label = label )) # type:ignore[index]
3498
3500
3499
3501
self ._sites = tuple (sites ) # type:ignore[arg-type]
3500
3502
if validate_proximity and not self .is_valid ():
@@ -3571,7 +3573,7 @@ def nelectrons(self) -> float:
3571
3573
return n_electrons
3572
3574
3573
3575
@property
3574
- def center_of_mass (self ) -> NDArray :
3576
+ def center_of_mass (self ) -> NDArray [ np . float64 ] :
3575
3577
"""Center of mass of molecule."""
3576
3578
center = np .zeros (3 )
3577
3579
total_weight : float = 0
0 commit comments