Skip to content

Commit 7b91243

Browse files
authored
Merge branch 'master' into fix-pd-plot-above-hull-e
2 parents c9e15e4 + 20b68ff commit 7b91243

File tree

20 files changed

+404
-239
lines changed

20 files changed

+404
-239
lines changed

.github/workflows/lint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v5
17+
1718
- name: Install uv with python version.
1819
uses: astral-sh/setup-uv@v6
1920
with:
20-
python-version: "3.11"
21+
python-version: "3.13"
2122
enable-cache: true
2223
cache-dependency-glob: "uv.lock"
24+
2325
- name: Install dependencies
2426
run: |
2527
uv sync

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Install Python
3131
uses: actions/setup-python@v6
3232
with:
33-
python-version: "3.13"
33+
python-version: "3.14"
3434

3535
- name: Build source distribution
3636
run: |
@@ -47,7 +47,7 @@ jobs:
4747
strategy:
4848
matrix:
4949
os: [ubuntu-latest, macos-latest, macos-13, windows-latest, ubuntu-24.04-arm]
50-
python-version: ["310", "311", "312", "313"]
50+
python-version: ["310", "311", "312", "313", "314"]
5151
runs-on: ${{ matrix.os }}
5252
steps:
5353
- name: Check out repo
@@ -77,7 +77,7 @@ jobs:
7777
- name: Set up Python
7878
uses: actions/setup-python@v6
7979
with:
80-
python-version: "3.13"
80+
python-version: "3.14"
8181

8282
- name: Get build artifacts
8383
uses: actions/download-artifact@v5

.github/workflows/test.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,26 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
# Maximize CI coverage of different platforms and python versions while minimizing the
43-
# total number of jobs. We run all pytest splits with the oldest supported python
44-
# version (currently 3.10) on windows (seems most likely to surface errors) and with
45-
# newest version (currently 3.13) on ubuntu (to get complete coverage on unix).
42+
# Maximize CI coverage of different platforms and Python versions while minimizing the
43+
# total number of jobs. We run all pytest splits with the oldest supported Python
44+
# version on windows (most likely to surface errors) and with
45+
# newest version on Ubuntu (to get complete coverage).
4646
config:
4747
- os: windows-latest
48-
python: "3.10"
49-
resolution: highest
48+
python: "3.10" # Test lowest supported Python version
49+
resolution: lowest-direct
5050
extras: optional,prototypes
5151
- os: windows-latest
5252
python: "3.11"
5353
resolution: highest
5454
extras: prototypes,optional,numpy-v1 # Test NP1 on Windows (quite buggy ATM)
5555
- os: macos-latest
56-
python: "3.12"
56+
python: "3.13"
5757
resolution: lowest-direct
5858
extras: prototypes # test with only required dependencies installed
5959
- os: ubuntu-latest
60-
python: "3.13"
61-
resolution: lowest-direct
60+
python: "3.14" # Test highest supported Python version
61+
resolution: highest
6262
extras: prototypes,optional
6363

6464
# pytest-split automatically distributes work load so parallel jobs finish in similar time
@@ -67,7 +67,7 @@ jobs:
6767

6868
runs-on: ${{ matrix.config.os }}
6969
env:
70-
OPT_BIN_DIR: ${{ github.workspace }}/opt/bin # for optional Unix dependencies
70+
OPT_BIN_DIR: ${{ github.workspace }}/opt/bin # for optional Ubuntu dependencies
7171
steps:
7272
- name: Check out repo
7373
uses: actions/checkout@v5

.pre-commit-config.yaml

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

99
repos:
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.13.3
11+
rev: v0.14.3
1212
hooks:
1313
- id: ruff
1414
args: [--fix, --unsafe-fixes]
@@ -38,7 +38,7 @@ repos:
3838
exclude: src/pymatgen/analysis/aflow_prototypes.json
3939

4040
- repo: https://github.com/MarcoGorelli/cython-lint
41-
rev: v0.17.0
41+
rev: v0.18.1
4242
hooks:
4343
- id: cython-lint
4444
args: [--no-pycodestyle]
@@ -67,6 +67,6 @@ repos:
6767
args: [--drop-empty-cells, --keep-output]
6868

6969
- repo: https://github.com/RobertCraigie/pyright-python
70-
rev: v1.1.406
70+
rev: v1.1.407
7171
hooks:
7272
- id: pyright

pyproject.toml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ classifiers = [
4949
"Programming Language :: Python :: 3.11",
5050
"Programming Language :: Python :: 3.12",
5151
"Programming Language :: Python :: 3.13",
52+
"Programming Language :: Python :: 3.14",
5253
"Topic :: Scientific/Engineering :: Chemistry",
5354
"Topic :: Scientific/Engineering :: Information Analysis",
5455
"Topic :: Scientific/Engineering :: Physics",
@@ -79,7 +80,7 @@ dependencies = [
7980
"tqdm>=4.60",
8081
"uncertainties>=3.1.4",
8182
]
82-
version = "2025.6.14"
83+
version = "2025.10.7"
8384

8485
[project.urls]
8586
Homepage = "https://pymatgen.org"
@@ -100,7 +101,7 @@ matcalc = [
100101
"matgl>=1.2.7; python_version<'3.13'",
101102
]
102103
mlp = ["matgl>=1.2.7 ; python_version<'3.13'"]
103-
numba = ["numba>=0.55"]
104+
numba = ["numba>=0.55; python_version<'3.14'"]
104105
numpy-v1 = ["numpy>=1.25.0,<2"] # Test NP1 on Windows (quite buggy ATM)
105106
optional = [
106107
"pymatgen[abinit,ase,matcalc,mlp,tblite,zeopp]",
@@ -112,7 +113,7 @@ optional = [
112113
"f90nml>=1.1.2",
113114
"galore>=0.6.1",
114115
"h5py>=3.11.0",
115-
"hiphive>=1.3.1",
116+
"hiphive>=1.3.1; python_version<'3.14'",
116117
"jarvis-tools>=2020.7.14",
117118
"phonopy>=2.33.3",
118119
"seekpath>=2.0.1",
@@ -123,7 +124,7 @@ symmetry = ["moyopy[interface]>=0.3", "spglib>=2.5"]
123124
# tblite only support Python 3.12+ through conda-forge
124125
# https://github.com/tblite/tblite/issues/175
125126
tblite = ["tblite[ase]>=0.3.0; platform_system=='Linux' and python_version<'3.12'"]
126-
vis = ["vtk>=6.0.0"]
127+
vis = ["vtk>=6.0.0; python_version<'3.14'"]
127128
zeopp = ["pyzeo; platform_system != 'Windows'"] # Note: requires Voro++ and Zeo++ to be installed
128129

129130
[project.scripts]
@@ -164,10 +165,6 @@ include = ["pymatgen", "pymatgen.*"]
164165
"pymatgen.io.lammps" = ["CoeffsDataType.yaml", "templates/*.template"]
165166
"pymatgen.symmetry" = ["*.json", "*.sqlite", "*.yaml"]
166167

167-
[tool.pdm.dev-dependencies]
168-
lint = ["mypy>=1.10.0", "pre-commit>=3.7.1", "ruff>=0.4.9"]
169-
test = ["pytest-cov>=5.0.0", "pytest-split>=0.9.0", "pytest>=8.2.2","pytest-xdist>=3.0.0"]
170-
171168
[tool.cibuildwheel.linux]
172169
archs = ["auto64"]
173170
skip = ["*musllinux*"]
@@ -261,7 +258,7 @@ docstring-code-format = true
261258
addopts = "-n auto --durations=30 --quiet -r xXs --color=yes --import-mode=importlib"
262259
filterwarnings = [
263260
# NOTE: the LAST matching option would be used
264-
"ignore::UserWarning", # Ignore UserWarning
261+
"ignore::UserWarning",
265262
]
266263

267264
[tool.coverage.run]
@@ -277,12 +274,7 @@ omit = [
277274
[tool.coverage.report]
278275
exclude_also = [
279276
"@deprecated",
280-
"def __repr__",
281277
"except ImportError:",
282-
"if TYPE_CHECKING:",
283-
"if self.debug:",
284-
"if settings.DEBUG",
285-
"pragma: no cover",
286278
"raise NotImplementedError",
287279
"show_plot",
288280
]

src/pymatgen/analysis/phase_diagram.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,17 @@ def __repr__(self) -> str:
406406

407407
def as_dict(self) -> dict[str, Any]:
408408
"""Get MSONable dict representation of PhaseDiagram."""
409+
410+
qhull_entry_indices = [self.all_entries.index(e) for e in self.qhull_entries]
411+
409412
return {
410413
"@module": type(self).__module__,
411414
"@class": type(self).__name__,
412-
"all_entries": [e.as_dict() for e in self.all_entries],
413415
"elements": [e.as_dict() for e in self.elements],
414-
"computed_data": self.computed_data,
416+
"computed_data": self.computed_data
417+
| {
418+
"qhull_entries": qhull_entry_indices,
419+
},
415420
}
416421

417422
@classmethod
@@ -423,9 +428,19 @@ def from_dict(cls, dct: dict[str, Any]) -> Self:
423428
Returns:
424429
PhaseDiagram
425430
"""
426-
entries = [MontyDecoder().process_decoded(entry) for entry in dct["all_entries"]]
427-
elements = [Element.from_dict(elem) for elem in dct["elements"]]
428431
computed_data = dct.get("computed_data")
432+
elements = [Element.from_dict(elem) for elem in dct["elements"]]
433+
434+
# for backwards compatibility, check for old format
435+
if "all_entries" in dct:
436+
entries = [MontyDecoder().process_decoded(entry) for entry in dct["all_entries"]]
437+
else:
438+
entries = [MontyDecoder().process_decoded(entry) for entry in computed_data["all_entries"]]
439+
440+
complete_qhull_entries = [computed_data["all_entries"][i] for i in computed_data["qhull_entries"]]
441+
442+
computed_data = computed_data | {"qhull_entries": complete_qhull_entries}
443+
429444
return cls(entries, elements, computed_data=computed_data)
430445

431446
def _compute(self) -> dict[str, Any]:

src/pymatgen/analysis/structure_prediction/dopant_predictor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def get_dopants_from_shannon_radii(bonded_structure, num_dopants=5, match_oxi_si
128128
def _get_dopants(substitutions, num_dopants, match_oxi_sign) -> dict:
129129
"""Utility method to get n- and p-type dopants from a list of substitutions."""
130130
dopants = {k: [] for k in ("n_type", "p_type")}
131-
for k in dopants: # noqa: PLC0206
131+
for k, dop in dopants.items():
132132
for pred in substitutions:
133133
if (
134134
pred["dopant_species"].oxi_state > pred["original_species"].oxi_state
@@ -138,8 +138,8 @@ def _get_dopants(substitutions, num_dopants, match_oxi_sign) -> dict:
138138
not match_oxi_sign
139139
or np.sign(pred["dopant_species"].oxi_state) == np.sign(pred["original_species"].oxi_state)
140140
):
141-
dopants[k].append(pred)
142-
if len(dopants[k]) == num_dopants:
141+
dop.append(pred)
142+
if len(dop) == num_dopants:
143143
break
144144
return dopants
145145

src/pymatgen/cli/pmg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def format_lists(v):
6363
["---------------", "", ""],
6464
]
6565
output += [
66-
( # type: ignore[misc]
66+
[
6767
k,
6868
format_lists(diff["Same"][k]),
6969
format_lists(diff["Same"][k]),
70-
)
70+
]
7171
for k in sorted(diff["Same"])
7272
if k != "SYSTEM"
7373
]
@@ -77,7 +77,7 @@ def format_lists(v):
7777
["----------------", "", ""],
7878
]
7979
output += [
80-
[ # type: ignore[misc]
80+
[
8181
k,
8282
format_lists(diff["Different"][k]["INCAR1"]),
8383
format_lists(diff["Different"][k]["INCAR2"]),

src/pymatgen/core/periodic_table.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,9 +1640,9 @@ def get_el_sp(obj: int | SpeciesLike) -> Element | Species | DummySpecies:
16401640
# If obj is an integer, return the Element with atomic number obj
16411641
try:
16421642
flt = float(obj)
1643-
assert flt == int(flt) # noqa: S101
1644-
return Element.from_Z(int(flt))
1645-
except (AssertionError, ValueError, TypeError, KeyError):
1643+
if flt.is_integer():
1644+
return Element.from_Z(int(flt))
1645+
except (ValueError, TypeError, KeyError):
16461646
pass
16471647

16481648
# If obj is a string, attempt to parse it as a Species

0 commit comments

Comments
 (0)