Skip to content

Commit 6c4806c

Browse files
committed
Merge branch 'master' of github.com:materialsvirtuallab/pymatgen-analysis-diffusion
2 parents add445a + 0cf3dca commit 6c4806c

24 files changed

+64
-69
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ ci:
88

99
repos:
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.12.7
11+
rev: v0.13.3
1212
hooks:
1313
- id: ruff
1414
args: [ --fix, --unsafe-fixes ]
1515
- id: ruff-format
1616

1717
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v5.0.0
18+
rev: v6.0.0
1919
hooks:
2020
- id: check-yaml
2121
- id: end-of-file-fixer
2222
- id: trailing-whitespace
2323

2424
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.17.1
25+
rev: v1.18.2
2626
hooks:
2727
- id: mypy
2828

@@ -35,14 +35,14 @@ repos:
3535
additional_dependencies: [ tomli ] # needed to read pyproject.toml below py3.11
3636

3737
- repo: https://github.com/MarcoGorelli/cython-lint
38-
rev: v0.16.7
38+
rev: v0.17.0
3939
hooks:
4040
- id: cython-lint
4141
args: [ --no-pycodestyle ]
4242
- id: double-quote-cython-strings
4343

4444
- repo: https://github.com/adamchainz/blacken-docs
45-
rev: 1.19.1
45+
rev: 1.20.0
4646
hooks:
4747
- id: blacken-docs
4848

@@ -64,6 +64,6 @@ repos:
6464
args: [ --drop-empty-cells, --keep-output ]
6565

6666
- repo: https://github.com/RobertCraigie/pyright-python
67-
rev: v1.1.403
67+
rev: v1.1.406
6868
hooks:
6969
- id: pyright

examples/neb_idpp_solver.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
"\n",
1111
"import os\n",
1212
"\n",
13-
"from pymatgen.analysis.diffusion.neb.pathfinder import IDPPSolver\n",
1413
"from pymatgen.core import Structure\n",
1514
"\n",
15+
"from pymatgen.analysis.diffusion.neb.pathfinder import IDPPSolver\n",
16+
"\n",
1617
"dirname = \"../pymatgen/analysis/diffusion/neb/tests/pathfinder_files/\"\n",
1718
"\n",
1819
"init_struct = Structure.from_file(os.path.join(dirname, \"CONTCAR-0\"), False)\n",

examples/probability_analysis.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"from __future__ import annotations\n",
3333
"\n",
3434
"import numpy as np\n",
35+
"from pymatgen.core import Structure\n",
3536
"\n",
3637
"from pymatgen.analysis.diffusion.aimd.pathway import ProbabilityDensityAnalysis\n",
37-
"from pymatgen.core import Structure\n",
3838
"\n",
3939
"# First prepare the structure and ionic trajectories files\n",
4040
"trajectories = np.load(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_trajectories.npy\")\n",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pymatgen==2025.6.14
1+
pymatgen==2025.10.7
22
joblib==1.5.2
33
ase==3.26.0
44
seaborn==0.13.2

src/pymatgen/analysis/diffusion/aimd/clustering.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import warnings
1111

1212
import numpy as np
13-
1413
from pymatgen.util.coord import all_distances, pbc_diff
1514

1615
__author__ = "Shyue Ping Ong"
@@ -161,15 +160,15 @@ def get_centroids(self, points, labels, k, centroids): # noqa: ANN001,ANN201
161160
k: Number of means
162161
centroids: List of centroids
163162
"""
164-
m, n = points.shape
163+
_m, n = points.shape
165164
labels = np.array(labels)
166165
new_centroids = []
167166
for i in range(k):
168167
ind = np.where(labels == i)[0]
169168
if len(ind) > 0:
170169
c = np.zeros(n)
171170
for j in ind:
172-
dist, image = self.lattice.get_distance_and_image(centroids[i], points[j])
171+
_dist, image = self.lattice.get_distance_and_image(centroids[i], points[j])
173172
c += points[j] + image
174173
c /= len(ind)
175174
c = np.mod(c, 1)
@@ -203,7 +202,7 @@ def get_random_centroid(points: np.ndarray) -> np.ndarray:
203202
Args:
204203
points: List of points.
205204
"""
206-
m, n = points.shape
205+
_m, n = points.shape
207206
maxd = np.max(points, axis=0)
208207
mind = np.min(points, axis=0)
209208
return np.array([random.uniform(mind[i], maxd[i]) for i in range(n)])

src/pymatgen/analysis/diffusion/aimd/pathway.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
if TYPE_CHECKING:
1414
from collections.abc import Sequence
1515

16-
from pymatgen.analysis.diffusion.analyzer import DiffusionAnalyzer
1716
from pymatgen.core.structure import Structure
1817
from pymatgen.util.typing import PathLike, SpeciesLike
1918

19+
from pymatgen.analysis.diffusion.analyzer import DiffusionAnalyzer
20+
2021

2122
class ProbabilityDensityAnalysis:
2223
r"""

src/pymatgen/analysis/diffusion/aimd/rdf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212

1313
import numpy as np
1414
from joblib import Parallel, delayed
15+
from pymatgen.core import Structure
16+
from pymatgen.util.plotting import pretty_plot
1517
from scipy.ndimage import gaussian_filter1d
1618
from scipy.signal import find_peaks
1719
from scipy.stats import norm
1820

19-
from pymatgen.core import Structure
20-
from pymatgen.util.plotting import pretty_plot
21-
2221
if TYPE_CHECKING:
2322
from collections.abc import Sequence
2423

src/pymatgen/analysis/diffusion/aimd/van_hove.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,20 @@
1414
import numpy as np
1515
import pandas as pd
1616
import seaborn as sns
17-
from scipy.stats import norm
18-
1917
from pymatgen.util.plotting import pretty_plot
18+
from scipy.stats import norm
2019

2120
from .rdf import RadialDistributionFunction
2221

2322
if TYPE_CHECKING:
2423
from collections.abc import Callable, Sequence
2524

2625
from matplotlib.axes import Axes
27-
28-
from pymatgen.analysis.diffusion.analyzer import DiffusionAnalyzer
2926
from pymatgen.core import Structure
3027
from pymatgen.util.typing import SpeciesLike
3128

29+
from pymatgen.analysis.diffusion.analyzer import DiffusionAnalyzer
30+
3231
__author__ = "Iek-Heng Chu"
3332
__version__ = "1.0"
3433
__date__ = "Aug 9, 2017"
@@ -87,7 +86,7 @@ def __init__(
8786
if step_skip <= 0:
8887
raise ValueError("skip_step should be >=1!")
8988

90-
n_ions, nsteps, ndim = diffusion_analyzer.disp.shape
89+
_n_ions, nsteps, _ndim = diffusion_analyzer.disp.shape
9190

9291
if nsteps <= avg_nsteps:
9392
raise ValueError("Number of timesteps is too small!")
@@ -515,7 +514,7 @@ def plot_evolution_from_data(
515514
plt.rcParams["ytick.labelsize"] = 20
516515
plt.rcParams["xtick.major.pad"] = 10
517516

518-
fig, ax = plt.subplots(figsize=(12, 8), facecolor="w")
517+
_fig, ax = plt.subplots(figsize=(12, 8), facecolor="w")
519518
ax = sns.heatmap(
520519
df,
521520
linewidths=0,

src/pymatgen/analysis/diffusion/analyzer.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,18 @@
2424
import numpy as np
2525
import scipy.constants as const
2626
from monty.json import MSONable
27-
from scipy.optimize import curve_fit
28-
2927
from pymatgen.analysis.structure_matcher import OrderDisorderElementComparator, StructureMatcher
3028
from pymatgen.core.periodic_table import get_el_sp
3129
from pymatgen.core.structure import Structure
3230
from pymatgen.io.vasp.outputs import Vasprun
3331
from pymatgen.util.coord import pbc_diff
3432
from pymatgen.util.plotting import pretty_plot
33+
from scipy.optimize import curve_fit
3534

3635
if TYPE_CHECKING:
3736
from collections.abc import Generator, Sequence
3837

3938
from matplotlib.axes import Axes
40-
4139
from pymatgen.util.typing import PathLike, SpeciesLike
4240

4341
__author__ = "Will Richards, Shyue Ping Ong"
@@ -250,7 +248,7 @@ def __init__(
250248
# drift corrected position
251249
dc = self.disp - drift
252250

253-
nions, nsteps, dim = dc.shape
251+
_nions, nsteps, _dim = dc.shape
254252

255253
self.indices = indices
256254

@@ -404,7 +402,7 @@ def get_drift_corrected_structures(
404402
coords = np.array(self.structure.cart_coords)
405403
species = self.structure.species_and_occu
406404
lattices = self.lattices
407-
nsites, nsteps, dim = self.corrected_displacements.shape
405+
_nsites, nsteps, _dim = self.corrected_displacements.shape
408406

409407
for i in range(start or 0, stop or nsteps, step or 1):
410408
latt = lattices[0] if len(lattices) == 1 else lattices[i]
@@ -960,7 +958,7 @@ def weighted_lstsq(a: np.ndarray, b: np.ndarray) -> tuple:
960958
# Get self diffusivity
961959
a = np.ones((len(dt), 2))
962960
a[:, 0] = dt
963-
(m, c), res, rank, s = weighted_lstsq(a, msd)
961+
(m, _c), res, _rank, _s = weighted_lstsq(a, msd)
964962
# m shouldn't be negative
965963
m = max(m, 1e-15)
966964

src/pymatgen/analysis/diffusion/neb/full_path_mapper.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
import networkx as nx
1919
import numpy as np
2020
from monty.json import MSONable
21-
22-
from pymatgen.analysis.diffusion.neb.pathfinder import ChgcarPotential, MigrationHop, NEBPathfinder
23-
from pymatgen.analysis.diffusion.neb.periodic_dijkstra import get_optimal_pathway_rev, periodic_dijkstra
24-
from pymatgen.analysis.diffusion.utils.parse_entries import process_entries
2521
from pymatgen.analysis.graphs import StructureGraph
2622
from pymatgen.analysis.local_env import MinimumDistanceNN, NearNeighbors
2723
from pymatgen.core import Composition, PeriodicSite, Structure
2824
from pymatgen.io.vasp import VolumetricData
2925
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
3026
from pymatgen.symmetry.structure import SymmetrizedStructure
3127

28+
from pymatgen.analysis.diffusion.neb.pathfinder import ChgcarPotential, MigrationHop, NEBPathfinder
29+
from pymatgen.analysis.diffusion.neb.periodic_dijkstra import get_optimal_pathway_rev, periodic_dijkstra
30+
from pymatgen.analysis.diffusion.utils.parse_entries import process_entries
31+
3232
if TYPE_CHECKING:
3333
from collections.abc import Callable, Generator
3434

@@ -515,7 +515,7 @@ def _setup_grids(self) -> None:
515515
bb = np.linspace(0, 1, len(self.potential_field.get_axis_grid(1)), endpoint=False)
516516
cc = np.linspace(0, 1, len(self.potential_field.get_axis_grid(2)), endpoint=False)
517517
# move the grid points to the center
518-
aa, bb, dd = map(_shift_grid, [aa, bb, cc])
518+
aa, bb, _dd = map(_shift_grid, [aa, bb, cc])
519519

520520
# mesh grid for each unit cell
521521
AA, BB, CC = np.meshgrid(aa, bb, cc, indexing="ij")

0 commit comments

Comments
 (0)