From 149e11544c62237421118770328171b02eca7b0d Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Sat, 7 Sep 2024 16:48:59 -0400 Subject: [PATCH] fix typos in AimsSpeciesFile and AimsOutCalcChunk --- .pre-commit-config.yaml | 6 ++--- src/pymatgen/io/aims/inputs.py | 40 ++++++++++++++++----------------- src/pymatgen/io/aims/parsers.py | 12 +++++----- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7596d1850a5..2a8967994f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ ci: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.0 + rev: v0.6.4 hooks: - id: ruff args: [--fix, --unsafe-fixes] @@ -22,7 +22,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.11.2 hooks: - id: mypy @@ -65,6 +65,6 @@ repos: args: [--drop-empty-cells, --keep-output] - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.376 + rev: v1.1.379 hooks: - id: pyright diff --git a/src/pymatgen/io/aims/inputs.py b/src/pymatgen/io/aims/inputs.py index 0935ead99f8..8dd8d01c1d2 100644 --- a/src/pymatgen/io/aims/inputs.py +++ b/src/pymatgen/io/aims/inputs.py @@ -705,35 +705,35 @@ def __init__(self, data: str, label: str | None = None) -> None: if "species" in line: self.label = line.split()[1] - def __eq__(self, sepcies_2: object) -> bool: - """Returns if two speceies are equal""" - if not isinstance(sepcies_2, AimsSpeciesFile): + def __eq__(self, other: object) -> bool: + """True if two species are equal.""" + if not isinstance(other, AimsSpeciesFile): return NotImplemented - return self.data == sepcies_2.data + return self.data == other.data - def __lt__(self, sepcies_2: object) -> bool: - """Returns if two speceies are equal""" - if not isinstance(sepcies_2, AimsSpeciesFile): + def __lt__(self, other: object) -> bool: + """True if self is less than other.""" + if not isinstance(other, AimsSpeciesFile): return NotImplemented - return self.data < sepcies_2.data + return self.data < other.data - def __le__(self, sepcies_2: object) -> bool: - """Returns if two speceies are equal""" - if not isinstance(sepcies_2, AimsSpeciesFile): + def __le__(self, other: object) -> bool: + """True if self is less than or equal to other.""" + if not isinstance(other, AimsSpeciesFile): return NotImplemented - return self.data <= sepcies_2.data + return self.data <= other.data - def __gt__(self, sepcies_2: object) -> bool: - """Returns if two speceies are equal""" - if not isinstance(sepcies_2, AimsSpeciesFile): + def __gt__(self, other: object) -> bool: + """True if self is greater than other.""" + if not isinstance(other, AimsSpeciesFile): return NotImplemented - return self.data > sepcies_2.data + return self.data > other.data - def __ge__(self, sepcies_2: object) -> bool: - """Returns if two speceies are equal""" - if not isinstance(sepcies_2, AimsSpeciesFile): + def __ge__(self, other: object) -> bool: + """True if self is greater than or equal to other.""" + if not isinstance(other, AimsSpeciesFile): return NotImplemented - return self.data >= sepcies_2.data + return self.data >= other.data @classmethod def from_file(cls, filename: str, label: str | None = None) -> AimsSpeciesFile: diff --git a/src/pymatgen/io/aims/parsers.py b/src/pymatgen/io/aims/parsers.py index fccc628e7e7..2566f6dad9c 100644 --- a/src/pymatgen/io/aims/parsers.py +++ b/src/pymatgen/io/aims/parsers.py @@ -3,10 +3,10 @@ from __future__ import annotations import gzip +import warnings from dataclasses import dataclass, field from pathlib import Path from typing import TYPE_CHECKING, cast -from warnings import warn import numpy as np @@ -498,7 +498,9 @@ def _parse_structure(self) -> Structure | Molecule: if ((magmom := site_properties.get("magmom")) is not None) and np.abs( np.sum(magmom) - properties["magmom"] ) < 1e-3: - warn("Total magenetic moment and sum of Mulliken spins are not consistent", Warning, 1) + warnings.warn( + "Total magnetic moment and sum of Mulliken spins are not consistent", UserWarning, stacklevel=1 + ) if lattice is not None: return Structure( @@ -517,9 +519,7 @@ def _parse_structure(self) -> Structure | Molecule: properties=properties, ) - def _parse_lattice_atom_pos( - self, - ) -> tuple[list[str], list[Vector3D], list[Vector3D], Lattice | None]: + def _parse_lattice_atom_pos(self) -> tuple[list[str], list[Vector3D], list[Vector3D], Lattice | None]: """Parse the lattice and atomic positions of the structure. Returns: @@ -545,7 +545,7 @@ def _parse_lattice_atom_pos( velocities = list(self.initial_structure.site_properties.get("velocity", [])) lattice = self.initial_lattice - return (species, coords, velocities, lattice) + return species, coords, velocities, lattice line_start += 1