Skip to content

Commit c03d2e4

Browse files
committed
up_sample
1 parent 64fc9ae commit c03d2e4

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

pymatgen/analysis/defects/ccd.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55
from dataclasses import dataclass
66
from itertools import groupby
7-
from typing import TYPE_CHECKING, Optional, Sequence, Tuple
7+
from typing import TYPE_CHECKING
88

99
import numpy as np
1010
from monty.json import MSONable
@@ -20,6 +20,7 @@
2020
if TYPE_CHECKING:
2121
from ctypes import Structure
2222
from pathlib import Path
23+
from typing import Optional, Sequence, Tuple
2324

2425
import numpy.typing as npt
2526
from matplotlib.axes import Axes
@@ -65,9 +66,9 @@ class HarmonicDefect(MSONable):
6566
charge_state: int
6667
ispin: int
6768
vrun: Optional[Vasprun] = None
68-
distortions: Optional[list[float]] = None
69-
structures: Optional[list[Structure]] = None
70-
energies: Optional[list[float]] = None
69+
distortions: Optional[Sequence[float]] = None
70+
structures: Optional[Sequence[Structure]] = None
71+
energies: Optional[Sequence[float]] = None
7172
defect_band: Optional[Sequence[tuple]] = None
7273
relaxed_index: Optional[int] = None
7374
relaxed_bandstructure: Optional[BandStructure] = None
@@ -234,7 +235,7 @@ def _parse_vasprun(vasprun: Vasprun):
234235
omega=omega,
235236
charge_state=charge_state,
236237
ispin=ispin,
237-
structures=structures,
238+
structures=list(structures),
238239
distortions=distortions,
239240
energies=energies,
240241
defect_band=defect_band,
@@ -313,7 +314,7 @@ def occupation(self, t: npt.ArrayLike | float) -> npt.ArrayLike:
313314
return 1.0 / (1 - np.exp(-self.omega_eV / KB * t))
314315

315316
def read_wswqs(
316-
self, directory: Path, distortions: list[float] | None = None
317+
self, directory: Path, distortions: Sequence[float] | None = None
317318
) -> None:
318319
"""Read the WSWQ files from a directory.
319320

pymatgen/analysis/defects/plotting/phases.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def plot_chempot_2d(
9090
)
9191
ax.add_patch(patch)
9292

93-
ax.set_xlabel(f"$\Delta\mu_{{{x_element}}}$ (eV)")
94-
ax.set_ylabel(f"$\Delta\mu_{{{y_element}}}$ (eV)")
93+
ax.set_xlabel(rf"$\Delta\mu_{{{x_element}}}$ (eV)")
94+
ax.set_ylabel(rf"$\Delta\mu_{{{y_element}}}$ (eV)")
9595
ax.set_xlim(x_min - PLOT_PADDING, 0 + PLOT_PADDING)
9696
ax.set_ylim(y_min - PLOT_PADDING, 0 + PLOT_PADDING)
9797
if label_lines:
@@ -102,7 +102,7 @@ def _convex_hull_2d(
102102
points: list[dict],
103103
x_element: Element,
104104
y_element: Element,
105-
competing_phases: list = None,
105+
competing_phases: list | None = None,
106106
) -> list[dict]:
107107
"""Compute the convex hull of a set of points in 2D.
108108

pymatgen/analysis/defects/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ def get_localized_states(
904904

905905
def sort_positive_definite(
906906
list_in: list, ref1: Any, ref2: Any, dist: Callable
907-
) -> tuple[list, list[float]]:
907+
) -> tuple[tuple, tuple[float]]:
908908
"""Sort a list where we can only compute a positive-definite distance.
909909
910910
Sometimes, we can only compute a positive-definite distance between two objects.

pyproject.toml

+4-8
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ line-length = 88
100100
indent-width = 4
101101

102102

103+
104+
[tool.ruff.lint]
105+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`).
103106
# By default, ruff only uses all "E" (pycodestyle) and "F" (pyflakes) rules.
104107
# Here we append to the defaults.
105108
select = [
@@ -127,9 +130,6 @@ select = [
127130
# (ruff-specific) Enable all ruff-specific checks (i.e. not ports of
128131
# functionality from an existing linter).
129132
"RUF",
130-
# (private member access) Flag access to `_`-prefixed symbols. By default the various special
131-
# methods on `NamedTuple` are ignored (e.g. `_replace`).
132-
"SLF001",
133133
# (flake8-type-checking) Auto-sort imports into TYPE_CHECKING blocks depending on whether
134134
# they are runtime or type-only imports.
135135
"TCH",
@@ -142,14 +142,10 @@ select = [
142142
# (invalid escape sequence) flag errant backslashes
143143
"W605",
144144
]
145-
146-
[tool.ruff.lint]
147-
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`).
148-
select = ["E4", "E7", "E9", "F", "D", "I001", "TCH"]
149145
ignore = ["E203", "E501", "F401"]
150146

151147
# Allow fix for all enabled rules (when `--fix`) is provided.
152-
fixable = ["ALL", "TCH"]
148+
fixable = ["ALL"]
153149
unfixable = []
154150

155151
# Allow unused variables when underscore-prefixed.

0 commit comments

Comments
 (0)