Skip to content

Commit 4c68bd5

Browse files
authored
Merge branch 'master' into dependabot/pip/pymatgen-2024.10.3
2 parents 966fc60 + d1f0a85 commit 4c68bd5

File tree

79 files changed

+194
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+194
-170
lines changed

.github/workflows/linting.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
python-version: [3.11]
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515
with:
1616
fetch-depth: 0
1717
- name: Set up Python ${{ matrix.python-version }}
@@ -21,11 +21,11 @@ jobs:
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
24-
pip install -r requirements-ci.txt --quiet
24+
pip install --upgrade -r requirements-ci.txt --quiet
2525
- name: mypy
2626
run: |
27-
mypy --namespace-packages --explicit-package-bases pymatgen
27+
mypy --namespace-packages --explicit-package-bases src
2828
- name: ruff
2929
run: |
30-
ruff check pymatgen
31-
ruff format pymatgen
30+
ruff check .
31+
ruff format .

.github/workflows/testing.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
MPLBACKEND: "Agg"
1818

1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: Set up Python ${{ matrix.python-version }}
2222
uses: actions/setup-python@v4
2323
with:
@@ -30,8 +30,8 @@ jobs:
3030
pip install -e '.[ci]'
3131
- name: pytest
3232
run: |
33-
python -m pytest --cov=pymatgen.analysis.diffusion --durations=30 pymatgen
33+
python -m pytest --cov=pymatgen.analysis.diffusion --durations=30 tests
3434
- name: Upload coverage reports to Codecov
35-
uses: codecov/codecov-action@v3
35+
uses: codecov/codecov-action@v4
3636
env:
3737
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.pre-commit-config.yaml

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

99
repos:
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.5.0
11+
rev: v0.9.9
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: v4.6.0
18+
rev: v5.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.10.1
25+
rev: v1.15.0
2626
hooks:
2727
- id: mypy
2828

2929
- repo: https://github.com/codespell-project/codespell
30-
rev: v2.3.0
30+
rev: v2.4.1
3131
hooks:
3232
- id: codespell
33-
stages: [ commit, commit-msg ]
33+
stages: [ pre-commit, commit-msg ]
3434
exclude_types: [ html ]
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.2
38+
rev: v0.16.6
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.16.0
45+
rev: 1.19.1
4646
hooks:
4747
- id: blacken-docs
4848

4949
- repo: https://github.com/igorshubovych/markdownlint-cli
50-
rev: v0.41.0
50+
rev: v0.44.0
5151
hooks:
5252
- id: markdownlint
5353
# MD013: line too long
@@ -58,12 +58,12 @@ repos:
5858
args: [ --disable, MD013, MD024, MD025, MD033, MD041, "--" ]
5959

6060
- repo: https://github.com/kynan/nbstripout
61-
rev: 0.7.1
61+
rev: 0.8.1
6262
hooks:
6363
- id: nbstripout
6464
args: [ --drop-empty-cells, --keep-output ]
6565

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

MANIFEST.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
include LICENSE COPYRIGHT *.md *.in requirements.txt
22
recursive-include pymatgen *.py
3-
recursive-include scripts *.py
4-
prune */tests
5-
prune */*/tests
6-
prune */*/*/tests

examples/neb_idpp_solver.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"from pymatgen.core import Structure\n",
10-
"from pymatgen.analysis.diffusion.neb.pathfinder import IDPPSolver\n",
11-
"import numpy as np\n",
9+
"from __future__ import annotations\n",
10+
"\n",
1211
"import os\n",
1312
"\n",
13+
"from pymatgen.analysis.diffusion.neb.pathfinder import IDPPSolver\n",
14+
"from pymatgen.core import Structure\n",
15+
"\n",
1416
"dirname = \"../pymatgen/analysis/diffusion/neb/tests/pathfinder_files/\"\n",
1517
"\n",
1618
"init_struct = Structure.from_file(os.path.join(dirname, \"CONTCAR-0\"), False)\n",
1719
"final_struct = Structure.from_file(os.path.join(dirname, \"CONTCAR-1\"), False)\n",
1820
"\n",
19-
"obj = IDPPSolver.from_endpoints(endpoints=[init_struct, final_struct], nimages=3, \n",
20-
" sort_tol=1.0)\n",
21+
"obj = IDPPSolver.from_endpoints(endpoints=[init_struct, final_struct], nimages=3, sort_tol=1.0)\n",
2122
"new_path = obj.run(maxiter=5000, tol=1e-5, gtol=1e-3, species=[\"Li\"])"
2223
]
2324
}

examples/neb_path_mapping.ipynb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
"outputs": [],
1515
"source": [
1616
"# Start with a lithiated structure\n",
17+
"from __future__ import annotations\n",
18+
"\n",
1719
"from pymatgen.core import Structure\n",
20+
"\n",
1821
"struct = Structure.from_file(\"../pymatgen/analysis/diffusion/neb/tests/full_path_files/Li6MnO4.cif\")"
1922
]
2023
},
@@ -25,7 +28,8 @@
2528
"outputs": [],
2629
"source": [
2730
"from pymatgen.analysis.diffusion.neb.full_path_mapper import MigrationGraph\n",
28-
"# Instantiate MigrationGraph and consider all hops within 4 Angstroms \n",
31+
"\n",
32+
"# Instantiate MigrationGraph and consider all hops within 4 Angstroms\n",
2933
"mg = MigrationGraph.with_distance(structure=struct, migrating_specie=\"Li\", max_distance=4)"
3034
]
3135
},
@@ -316,7 +320,7 @@
316320
"source": [
317321
"# Get migration paths through the material of interest using the MigrationGraph hop data\n",
318322
"paths = []\n",
319-
"for u, path in mg.get_path():\n",
323+
"for _u, path in mg.get_path():\n",
320324
" paths.append(path)"
321325
]
322326
},
@@ -389,14 +393,14 @@
389393
}
390394
],
391395
"source": [
392-
"print(\"Number of paths =\", len(paths), \"\\n\\nA example of a path of length\", len(paths[0]))\n",
396+
"print(f\"Number of paths = {len(paths)} \\n\\nA example of a path of length {len(paths[0])}\")\n",
393397
"paths[0]"
394398
]
395399
}
396400
],
397401
"metadata": {
398402
"kernelspec": {
399-
"display_name": "Python 3",
403+
"display_name": "Python 3 (ipykernel)",
400404
"language": "python",
401405
"name": "python3"
402406
},
@@ -410,7 +414,7 @@
410414
"name": "python",
411415
"nbconvert_exporter": "python",
412416
"pygments_lexer": "ipython3",
413-
"version": "3.7.9"
417+
"version": "3.11.10"
414418
}
415419
},
416420
"nbformat": 4,

examples/probability_analysis.ipynb

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,25 @@
2929
}
3030
],
3131
"source": [
32+
"from __future__ import annotations\n",
33+
"\n",
34+
"import numpy as np\n",
35+
"\n",
3236
"from pymatgen.analysis.diffusion.aimd.pathway import ProbabilityDensityAnalysis\n",
3337
"from pymatgen.core import Structure\n",
34-
"import numpy as np\n",
3538
"\n",
36-
"#First prepare the structure and ionic trajectories files\n",
39+
"# First prepare the structure and ionic trajectories files\n",
3740
"trajectories = np.load(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_trajectories.npy\")\n",
3841
"structure = Structure.from_file(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4.cif\", False)\n",
3942
"\n",
40-
"#ProbabilityDensityAnalysis object\n",
43+
"# ProbabilityDensityAnalysis object\n",
4144
"pda = ProbabilityDensityAnalysis(structure, trajectories, interval=0.5)\n",
42-
"#Save probability distribution to a CHGCAR-like file\n",
45+
"# Save probability distribution to a CHGCAR-like file\n",
4346
"pda.to_chgcar(filename=\"CHGCAR_new.vasp\")\n",
4447
"\n",
45-
"print(\"Maximum: %s, Minimum: %s\" % (pda.Pr.max(), pda.Pr.min()))\n",
48+
"print(f\"Maximum: {pda.Pr.max()}, Minimum: {pda.Pr.min()}\")\n",
4649
"# \\int P(r)d^3r = 1\n",
47-
"print(\"Total probability: %s\" % np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0]/pda.lens[1]/pda.lens[2]))\n"
50+
"print(f\"Total probability: {np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0] / pda.lens[1] / pda.lens[2])}\")"
4851
]
4952
},
5053
{
@@ -69,29 +72,29 @@
6972
}
7073
],
7174
"source": [
72-
"from pymatgen.analysis.diffusion.analyzer import DiffusionAnalyzer\n",
7375
"import json\n",
7476
"\n",
75-
"#ProbabilityDensityAnalysis object\n",
76-
"filename=\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\"\n",
77+
"from pymatgen.analysis.diffusion.analyzer import DiffusionAnalyzer\n",
78+
"\n",
79+
"# ProbabilityDensityAnalysis object\n",
80+
"filename = \"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\"\n",
7781
"\n",
78-
"data = json.load(open(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\", \"r\"))\n",
82+
"data = json.load(open(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\"))\n",
7983
"diff_analyzer = DiffusionAnalyzer.from_dict(data)\n",
8084
"\n",
81-
"pda = ProbabilityDensityAnalysis.from_diffusion_analyzer(diff_analyzer, interval=0.5,\n",
82-
" species=(\"Na\", \"Li\"))\n",
83-
"#Save probability distribution to a CHGCAR-like file\n",
85+
"pda = ProbabilityDensityAnalysis.from_diffusion_analyzer(diff_analyzer, interval=0.5, species=(\"Na\", \"Li\"))\n",
86+
"# Save probability distribution to a CHGCAR-like file\n",
8487
"pda.to_chgcar(filename=\"CHGCAR_new2.vasp\")\n",
8588
"\n",
86-
"print(\"Maximum: %s, Minimum: %s\" % (pda.Pr.max(), pda.Pr.min()))\n",
89+
"print(f\"Maximum: {pda.Pr.max()}, Minimum: {pda.Pr.min()}\")\n",
8790
"# \\int P(r)d^3r = 1\n",
88-
"print(\"Total probability: %s\" % np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0]/pda.lens[1]/pda.lens[2]))\n"
91+
"print(f\"Total probability: {np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0] / pda.lens[1] / pda.lens[2])}\")"
8992
]
9093
}
9194
],
9295
"metadata": {
9396
"kernelspec": {
94-
"display_name": "Python 3",
97+
"display_name": "Python 3 (ipykernel)",
9598
"language": "python",
9699
"name": "python3"
97100
},
@@ -105,9 +108,9 @@
105108
"name": "python",
106109
"nbconvert_exporter": "python",
107110
"pygments_lexer": "ipython3",
108-
"version": "3.8.8"
111+
"version": "3.11.10"
109112
}
110113
},
111114
"nbformat": 4,
112-
"nbformat_minor": 1
115+
"nbformat_minor": 4
113116
}

0 commit comments

Comments
 (0)