diff --git a/pymatgen/core/trajectory.py b/pymatgen/core/trajectory.py index 044f08f636d..e7c32dcb59c 100644 --- a/pymatgen/core/trajectory.py +++ b/pymatgen/core/trajectory.py @@ -423,19 +423,19 @@ def write_Xdatcar( syms = [site.specie.symbol for site in self[0]] n_atoms = [len(tuple(a[1])) for a in itertools.groupby(syms)] - for si, coords in enumerate(self.coords): + for idx, coords in enumerate(self.coords): # Only print out the info block if - if si == 0 or not self.constant_lattice: + if idx == 0 or not self.constant_lattice: lines.extend([system, "1.0"]) - _lattice = self.lattice if self.constant_lattice else self.lattice[si] # type: ignore + _lattice = self.lattice if self.constant_lattice else self.lattice[idx] # type: ignore for latt_vec in _lattice: lines.append(f'{" ".join(map(str, latt_vec))}') lines.extend((" ".join(site_symbols), " ".join(map(str, n_atoms)))) - lines.append(f"Direct configuration= {si + 1}") + lines.append(f"Direct configuration= {idx + 1}") for coord, specie in zip(coords, self.species): line = f'{" ".join(format_str.format(c) for c in coord)} {specie}' diff --git a/pymatgen/io/core.py b/pymatgen/io/core.py index 2869256dff2..0064c9a4af5 100644 --- a/pymatgen/io/core.py +++ b/pymatgen/io/core.py @@ -144,7 +144,7 @@ def __getattr__(self, key): raise AttributeError(f"'{type(self).__name__}' object has no attribute {key!r}") def __copy__(self) -> InputSet: - cls = self.__class__ + cls = type(self) new_instance = cls.__new__(cls) for key, val in self.__dict__.items(): @@ -153,7 +153,7 @@ def __copy__(self) -> InputSet: return new_instance def __deepcopy__(self, memo: dict[int, InputSet]) -> InputSet: - cls = self.__class__ + cls = type(self) new_instance = cls.__new__(cls) memo[id(self)] = new_instance @@ -233,7 +233,7 @@ def from_directory(cls, directory: str | Path): Args: directory: Directory to read input files from """ - raise NotImplementedError(f"from_directory has not been implemented in {cls}") + raise NotImplementedError(f"from_directory has not been implemented in {cls.__name__}") def validate(self) -> bool: """ @@ -242,7 +242,7 @@ def validate(self) -> bool: Will raise a NotImplementedError unless overloaded by the inheriting class. """ - raise NotImplementedError(f".validate() has not been implemented in {self.__class__}") + raise NotImplementedError(f".validate() has not been implemented in {type(self).__name__}") class InputGenerator(MSONable): diff --git a/pymatgen/io/lammps/sets.py b/pymatgen/io/lammps/sets.py index d8233be1278..d303b5ad30a 100644 --- a/pymatgen/io/lammps/sets.py +++ b/pymatgen/io/lammps/sets.py @@ -96,4 +96,4 @@ def validate(self) -> bool: input set. Can be as simple or as complex as desired. Will raise a NotImplementedError unless overloaded by the inheriting class. """ - raise NotImplementedError(f".validate() has not been implemented in {self.__class__}") + raise NotImplementedError(f".validate() has not been implemented in {type(self).__name__}") diff --git a/pymatgen/io/packmol.py b/pymatgen/io/packmol.py index 2be21cfa742..a7506a2eacd 100644 --- a/pymatgen/io/packmol.py +++ b/pymatgen/io/packmol.py @@ -95,7 +95,7 @@ def from_directory(cls, directory: str | Path): Args: directory (str | Path): Directory to read input files from. """ - raise NotImplementedError(f"from_directory has not been implemented in {cls}") + raise NotImplementedError(f"from_directory has not been implemented in {cls.__name__}") class PackmolBoxGen(InputGenerator): diff --git a/pymatgen/io/res.py b/pymatgen/io/res.py index 9cd9e6b1f2d..684e42c03ac 100644 --- a/pymatgen/io/res.py +++ b/pymatgen/io/res.py @@ -397,7 +397,7 @@ def __init__(self, res: Res, parse_rems: Literal["gentle", "strict"] = "gentle") """The :func:`from_str` and :func:`from_file` methods should be used instead of constructing this directly.""" super().__init__(res) if self._res.TITL is None: - raise ResError(f"{self.__class__} can only be constructed from a res file with a valid TITL entry.") + raise ResError(f"{type(self).__name__} can only be constructed from a res file with a valid TITL entry.") if parse_rems not in ["gentle", "strict"]: raise ValueError(f"{parse_rems} not valid, must be either 'gentle' or 'strict'.") self._TITL = self._res.TITL # alias for the object so it is guarded by the None check diff --git a/tests/core/slab.cif b/tests/core/slab.cif deleted file mode 100644 index c55f8cacef3..00000000000 --- a/tests/core/slab.cif +++ /dev/null @@ -1,38 +0,0 @@ -# generated using pymatgen -data_Ti5O -_symmetry_space_group_name_H-M 'P 1' -_cell_length_a 4.60000000 -_cell_length_b 4.60000000 -_cell_length_c 22.56000000 -_cell_angle_alpha 90.00000000 -_cell_angle_beta 90.00000000 -_cell_angle_gamma 120.00000000 -_symmetry_Int_Tables_number 1 -_chemical_formula_structural Ti5O -_chemical_formula_sum 'Ti10 O2' -_cell_volume 413.41420059 -_cell_formula_units_Z 2 -loop_ - _symmetry_equiv_pos_site_id - _symmetry_equiv_pos_as_xyz - 1 'x, y, z' -loop_ - _atom_site_type_symbol - _atom_site_label - _atom_site_symmetry_multiplicity - _atom_site_fract_x - _atom_site_fract_y - _atom_site_fract_z - _atom_site_occupancy - Ti Ti1 1 0.000000 0.000000 0.093750 1 - Ti Ti2 1 0.000000 0.000000 0.218750 1 - Ti Ti3 1 0.333333 0.666667 0.156250 1 - Ti Ti4 1 0.666667 0.333333 0.156250 1 - Ti Ti5 1 0.000000 0.000000 0.343750 1 - Ti Ti6 1 0.333333 0.666667 0.281250 1 - Ti Ti7 1 0.666667 0.333333 0.281250 1 - Ti Ti8 1 0.000000 0.000000 0.468750 1 - Ti Ti9 1 0.333333 0.666667 0.406250 1 - Ti Ti10 1 0.666667 0.333333 0.406250 1 - O O11 1 0.000000 0.000000 0.568750 1 - O O12 1 0.000000 0.000000 -0.006250 1