Skip to content

Commit 78fb799

Browse files
committed
More cleanup.
1 parent e70a3cf commit 78fb799

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ ignore_missing_imports = true
302302
namespace_packages = true
303303
no_implicit_optional = false
304304
disable_error_code = ["annotation-unchecked", "override", "operator", "attr-defined", "union-attr", "misc", "call-overload", "call-arg", "var-annotated"] #, "operator", "arg-type", "index", "call-arg", "return-value", "assignment", "attr-defined"]
305-
exclude = ['src/pymatgen/analysis', 'src/pymatgen/phonon', 'src/pymatgen/io/lobster', 'src/pymatgen/io/cp2k', 'src/pymatgen/io/aims', 'src/pymatgen/io/lammps']
305+
exclude = ['src/pymatgen/analysis', 'src/pymatgen/phonon', 'src/pymatgen/io/lobster', 'src/pymatgen/io/cp2k', 'src/pymatgen/io/lammps']
306306
plugins = ["numpy.typing.mypy_plugin"]
307307

308308
[[tool.mypy.overrides]]

src/pymatgen/io/aims/inputs.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ def from_str(cls, contents: str) -> Self:
109109

110110
site_props = {"magmom": magmom, "charge": charge}
111111
if velocities_dct:
112-
site_props["velocity"] = velocity
112+
site_props["velocity"] = np.array(velocity) # type:ignore[assignment]
113113

114114
if lattice is None:
115-
structure = Molecule(species, coords, np.sum(charge), site_properties=site_props)
115+
structure = Molecule(species, coords, np.sum(charge), site_properties=site_props) # type:ignore[arg-type]
116116
else:
117-
structure = Structure(
117+
structure = Structure( # type:ignore[assignment]
118118
lattice,
119119
species,
120120
coords,
121-
np.sum(charge),
121+
np.sum(charge), # type:ignore[arg-type]
122122
coords_are_cartesian=True,
123123
site_properties=site_props,
124124
)
@@ -137,7 +137,7 @@ def from_file(cls, filepath: str | Path) -> Self:
137137
"""
138138
with zopen(filepath, mode="rt", encoding="utf-8") as in_file:
139139
content = in_file.read()
140-
return cls.from_str(content)
140+
return cls.from_str(content) # type:ignore[arg-type]
141141

142142
@classmethod
143143
def from_structure(cls, structure: Structure | IStructure | Molecule) -> Self:
@@ -180,7 +180,7 @@ def from_structure(cls, structure: Structure | IStructure | Molecule) -> Self:
180180
if (v is not None) and any(v_i != 0.0 for v_i in v):
181181
content_lines.append(f" velocity {' '.join([f'{v_i:.12e}' for v_i in v])}")
182182

183-
return cls(_content="\n".join(content_lines), _structure=structure)
183+
return cls(_content="\n".join(content_lines), _structure=structure) # type:ignore[arg-type]
184184

185185
@property
186186
def structure(self) -> Structure | Molecule:
@@ -232,7 +232,7 @@ def as_dict(self) -> dict[str, Any]:
232232
dct["@module"] = type(self).__module__
233233
dct["@class"] = type(self).__name__
234234
dct["content"] = self.content
235-
dct["structure"] = self.structure
235+
dct["structure"] = self.structure # type:ignore[assignment]
236236
return dct
237237

238238
@classmethod
@@ -303,7 +303,7 @@ class AimsCube(MSONable):
303303

304304
type: str = field(default_factory=str)
305305
origin: Sequence[float] | tuple[float, float, float] = field(default_factory=lambda: [0.0, 0.0, 0.0])
306-
edges: Sequence[Sequence[float]] = field(default_factory=lambda: 0.1 * np.eye(3))
306+
edges: Sequence[Sequence[float]] = field(default_factory=lambda: 0.1 * np.eye(3)) # type:ignore[return-value, arg-type]
307307
points: Sequence[int] | tuple[int, int, int] = field(default_factory=lambda: [0, 0, 0])
308308
format: str = "cube"
309309
spin_state: int | None = None
@@ -766,7 +766,7 @@ def from_file(cls, filename: str, label: str | None = None) -> Self:
766766
AimsSpeciesFile
767767
"""
768768
with zopen(filename, mode="rt", encoding="utf-8") as file:
769-
return cls(data=file.read(), label=label)
769+
return cls(data=file.read(), label=label) # type:ignore[arg-type]
770770

771771
@classmethod
772772
def from_element_and_basis_name(

src/pymatgen/io/aims/outputs.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,19 @@ def forces(self) -> Sequence[tuple[float, float, float]] | None:
206206
@property
207207
def stress(
208208
self,
209-
) -> Sequence[Sequence[float, float, float], Sequence[float, float, float], Sequence[float, float, float]]:
209+
) -> np.ndarray:
210210
"""The stress for the final image of the calculation."""
211211
return self.get_results_for_image(-1).properties.get("stress", None)
212212

213213
@property
214214
def stresses(
215215
self,
216-
) -> (
217-
Sequence[Sequence[Sequence[float, float, float], Sequence[float, float, float], Sequence[float, float, float]]]
218-
| None
219-
):
216+
) -> list[list[float]] | None:
220217
"""The atomic virial stresses for the final image of the calculation."""
221218
stresses_array = self.get_results_for_image(-1).site_properties.get("atomic_virial_stress", None)
222219
if isinstance(stresses_array, np.ndarray):
223220
return stresses_array.tolist()
224-
return stresses_array
221+
return stresses_array # type:ignore[return-value]
225222

226223
@property
227224
def all_forces(self) -> list[list[tuple[float, float, float]]]:

src/pymatgen/io/aims/parsers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def _parse_initial_charges_and_moments(self) -> None:
300300
magmoms = None
301301
else:
302302
charges[ll] = float(inp[3])
303-
magmoms[ll] = float(inp[2])
303+
magmoms[ll] = float(inp[2]) # type:ignore[index]
304304

305305
self._cache["initial_charges"] = charges
306306
self._cache["initial_magnetic_moments"] = magmoms
@@ -476,7 +476,7 @@ def _parse_structure(self) -> Structure | Molecule:
476476

477477
site_properties: dict[str, Sequence[Any]] = {}
478478
if len(velocities) > 0:
479-
site_properties["velocity"] = np.array(velocities)
479+
site_properties["velocity"] = np.array(velocities) # type:ignore [assignment]
480480

481481
results = self.results
482482
site_prop_keys = {
@@ -641,14 +641,14 @@ def stresses(self) -> np.ndarray | None:
641641
stresses = []
642642
for line in self.lines[line_start : line_start + self.n_atoms]:
643643
xx, yy, zz, xy, xz, yz = (float(d) for d in line.split()[2:8])
644-
stresses.append(Tensor.from_voigt([xx, yy, zz, yz, xz, xy]))
644+
stresses.append(Tensor.from_voigt([xx, yy, zz, yz, xz, xy])) # type:ignore [arg-type]
645645

646646
return np.array(stresses) * EV_PER_A3_TO_KBAR
647647

648648
@property
649649
def stress(
650650
self,
651-
) -> Sequence[Sequence[float, float, float], Sequence[float, float, float], Sequence[float, float, float]] | None:
651+
) -> np.ndarray | None:
652652
"""The stress from the aims.out file and convert to kBar."""
653653
line_start = self.reverse_search_for(
654654
["Analytical stress tensor - Symmetrized", "Numerical stress tensor"]
@@ -680,7 +680,7 @@ def energy(self) -> float:
680680
return float(self.lines[line_ind].split()[5])
681681

682682
@property
683-
def dipole(self) -> tuple[float, float, float] | None:
683+
def dipole(self) -> np.ndarray | None:
684684
"""The electric dipole moment from the aims.out file."""
685685
line_start = self.reverse_search_for(["Total dipole moment [eAng]"])
686686
if line_start == LINE_NOT_FOUND:
@@ -692,7 +692,7 @@ def dipole(self) -> tuple[float, float, float] | None:
692692
@property
693693
def dielectric_tensor(
694694
self,
695-
) -> Sequence[Sequence[float, float, float], Sequence[float, float, float], Sequence[float, float, float]] | None:
695+
) -> np.ndarray | None:
696696
"""The dielectric tensor from the aims.out file."""
697697
line_start = self.reverse_search_for(["PARSE DFPT_dielectric_tensor"])
698698
if line_start == LINE_NOT_FOUND:
@@ -705,7 +705,7 @@ def dielectric_tensor(
705705
return np.array([np.fromstring(line, sep=" ") for line in lines])
706706

707707
@property
708-
def polarization(self) -> tuple[float, float, float] | None:
708+
def polarization(self) -> np.ndarray | None:
709709
"""The polarization vector from the aims.out file."""
710710
line_start = self.reverse_search_for(["| Cartesian Polarization"])
711711
if line_start == LINE_NOT_FOUND:

src/pymatgen/io/aims/sets/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def d2k(
396396
recip_cell = structure.lattice.inv_matrix.transpose()
397397
return self.d2k_recip_cell(recip_cell, structure.lattice.pbc, kpt_density, even)
398398

399-
def k2d(self, structure: Structure | IStructure, k_grid: np.ndarray[int]):
399+
def k2d(self, structure: Structure | IStructure, k_grid: np.ndarray):
400400
"""Generate the kpoint density in each direction from given k_grid.
401401
402402
Args:

0 commit comments

Comments
 (0)