@@ -1386,7 +1386,7 @@ def get_sites_in_sphere(
1386
1386
is included in the returned data
1387
1387
1388
1388
Returns:
1389
- [:class:`pymatgen.core.structure. PeriodicNeighbor`]
1389
+ PeriodicNeighbor
1390
1390
"""
1391
1391
site_fcoords = np .mod (self .frac_coords , 1 )
1392
1392
neighbors : list [PeriodicNeighbor ] = []
@@ -1423,7 +1423,7 @@ def get_neighbors(
1423
1423
is always included in the returned data.
1424
1424
1425
1425
Returns:
1426
- [:class:`pymatgen.core.structure. PeriodicNeighbor`]
1426
+ PeriodicNeighbor
1427
1427
"""
1428
1428
return self .get_all_neighbors (r , include_index = include_index , include_image = include_image , sites = [site ])[0 ]
1429
1429
@@ -1442,7 +1442,7 @@ def get_neighbors_old(self, site, r, include_index=False, include_image=False):
1442
1442
is included in the returned data
1443
1443
1444
1444
Returns:
1445
- [:class:`pymatgen.core.structure. PeriodicNeighbor`]
1445
+ PeriodicNeighbor
1446
1446
"""
1447
1447
nn = self .get_sites_in_sphere (site .coords , r , include_index = include_index , include_image = include_image )
1448
1448
return [d for d in nn if site != d [0 ]]
@@ -1903,7 +1903,7 @@ def get_all_neighbors_old(self, r, include_index=False, include_image=False, inc
1903
1903
data. Defaults to True.
1904
1904
1905
1905
Returns:
1906
- [:class:`pymatgen.core.structure. PeriodicNeighbor`]
1906
+ PeriodicNeighbor
1907
1907
"""
1908
1908
# Use same algorithm as get_sites_in_sphere to determine supercell but
1909
1909
# loop over all atoms in crystal
@@ -3160,7 +3160,7 @@ def as_dict(self):
3160
3160
return d
3161
3161
3162
3162
@classmethod
3163
- def from_dict (cls , d ) -> dict :
3163
+ def from_dict (cls , d ) -> IMolecule | Molecule :
3164
3164
"""
3165
3165
Reconstitute a Molecule object from a dict representation created using
3166
3166
as_dict().
@@ -3198,7 +3198,7 @@ def get_sites_in_sphere(self, pt: ArrayLike, r: float) -> list[Neighbor]:
3198
3198
r (float): Radius of sphere.
3199
3199
3200
3200
Returns:
3201
- [:class:`pymatgen.core.structure. Neighbor`]
3201
+ Neighbor
3202
3202
"""
3203
3203
neighbors = []
3204
3204
for i , site in enumerate (self ._sites ):
@@ -3217,7 +3217,7 @@ def get_neighbors(self, site: Site, r: float) -> list[Neighbor]:
3217
3217
r (float): Radius of sphere.
3218
3218
3219
3219
Returns:
3220
- [:class:`pymatgen.core.structure. Neighbor`]
3220
+ Neighbor
3221
3221
"""
3222
3222
nns = self .get_sites_in_sphere (site .coords , r )
3223
3223
return [nn for nn in nns if nn != site ]
@@ -3233,7 +3233,7 @@ def get_neighbors_in_shell(self, origin: ArrayLike, r: float, dr: float) -> list
3233
3233
dr (float): Width of shell.
3234
3234
3235
3235
Returns:
3236
- [:class:`pymatgen.core.structure. Neighbor`]
3236
+ Neighbor
3237
3237
"""
3238
3238
outer = self .get_sites_in_sphere (origin , r + dr )
3239
3239
inner = r - dr
@@ -3429,7 +3429,9 @@ def to(self, filename: str = "", fmt: str = "") -> str | None:
3429
3429
return str (writer )
3430
3430
3431
3431
@classmethod
3432
- def from_str (cls , input_string : str , fmt : str ):
3432
+ def from_str (
3433
+ cls , input_string : str , fmt : Literal ["xyz" , "gjf" , "g03" , "g09" , "com" , "inp" , "json" , "yaml" ]
3434
+ ) -> IMolecule | Molecule :
3433
3435
"""
3434
3436
Reads the molecule from a string.
3435
3437
@@ -3448,21 +3450,21 @@ def from_str(cls, input_string: str, fmt: str):
3448
3450
from pymatgen .io .xyz import XYZ
3449
3451
3450
3452
if fmt .lower () == "xyz" :
3451
- m = XYZ .from_str (input_string ).molecule
3453
+ mol = XYZ .from_str (input_string ).molecule
3452
3454
elif fmt in ["gjf" , "g03" , "g09" , "com" , "inp" ]:
3453
- m = GaussianInput .from_str (input_string ).molecule
3455
+ mol = GaussianInput .from_str (input_string ).molecule
3454
3456
elif fmt == "json" :
3455
- d = json .loads (input_string )
3456
- return cls .from_dict (d )
3457
+ dct = json .loads (input_string )
3458
+ return cls .from_dict (dct )
3457
3459
elif fmt == "yaml" :
3458
3460
yaml = YAML ()
3459
- d = yaml .load (input_string )
3460
- return cls .from_dict (d )
3461
+ dct = yaml .load (input_string )
3462
+ return cls .from_dict (dct )
3461
3463
else :
3462
3464
from pymatgen .io .babel import BabelMolAdaptor
3463
3465
3464
- m = BabelMolAdaptor .from_str (input_string , file_format = fmt ).pymatgen_mol
3465
- return cls .from_sites (m )
3466
+ mol = BabelMolAdaptor .from_str (input_string , file_format = fmt ).pymatgen_mol
3467
+ return cls .from_sites (mol )
3466
3468
3467
3469
@classmethod
3468
3470
def from_file (cls , filename ):
0 commit comments