diff --git a/.github/workflows/issue-metrics.yml b/.github/workflows/issue-metrics.yml index 26e498a56ae..484dd0effcd 100644 --- a/.github/workflows/issue-metrics.yml +++ b/.github/workflows/issue-metrics.yml @@ -9,6 +9,8 @@ permissions: jobs: build: + # prevent this action from running on forks + if: github.repository == 'materialsproject/pymatgen' name: issue metrics runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b6d5930dd17..dc2b8238851 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,11 +35,11 @@ jobs: resolution: highest extras: ci,optional - os: ubuntu-latest - python: '>3.9' + python: ">3.9" resolution: lowest-direct extras: ci,optional - os: macos-latest - python: '3.10' + python: "3.10" resolution: lowest-direct extras: ci # test with only required dependencies installed @@ -70,18 +70,29 @@ jobs: - name: Install ubuntu-only conda dependencies if: matrix.config.os == 'ubuntu-latest' run: | - micromamba install -n pmg -c conda-forge enumlib packmol bader openbabel openff-toolkit --yes + micromamba install -n pmg -c conda-forge enumlib packmol bader openbabel openff-toolkit pygraphviz --yes - name: Install pymatgen and dependencies run: | micromamba activate pmg + # TODO remove temporary fix. added since uv install torch is flaky. # track https://github.com/astral-sh/uv/issues/1921 for resolution pip install torch --upgrade - uv pip install numpy cython + uv pip install cython setuptools wheel + uv pip install --editable '.[${{ matrix.config.extras }}]' --resolution=${{ matrix.config.resolution }} + - name: Install optional Ubuntu dependencies + if: matrix.config.os == 'ubuntu-latest' + run: | + micromamba activate pmg + + # TODO: uv cannot install BoltzTraP2 (#3786), + # suggesting no NumPy when there is + pip install BoltzTraP2 + - name: pytest split ${{ matrix.split }} run: | micromamba activate pmg diff --git a/.gitignore b/.gitignore index 2ac37aea6df..8179e082ca9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,6 @@ __pycache__/ .DS_Store pymatgen.egg-info -dependencies/PyCifRW-3.3/PyCifRW.egg-info -dependencies/spglib*/pyspglib.egg-info -dependencies/spglib*/build *.o *.so *.pyc @@ -26,7 +23,6 @@ setuptools* .cache .tox .eggs/ -gulptmp_4_1 .coverage .*_cache # VS Code diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bba0fa50a46..ad419dd514f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,16 +2,16 @@ exclude: ^(docs|tests/files|tasks.py) ci: autoupdate_schedule: monthly - skip: [ mypy, pyright ] + skip: [mypy, pyright] autofix_commit_msg: pre-commit auto-fixes autoupdate_commit_msg: pre-commit autoupdate repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.0 + rev: v0.5.6 hooks: - id: ruff - args: [ --fix, --unsafe-fixes ] + args: [--fix, --unsafe-fixes] - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks @@ -22,24 +22,25 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.1 + rev: v1.11.1 hooks: - id: mypy + entry: env MYPYPATH=src mypy - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: - id: codespell - stages: [ commit, commit-msg ] - exclude_types: [ html ] - additional_dependencies: [ tomli ] # needed to read pyproject.toml below py3.11 + stages: [commit, commit-msg] + exclude_types: [html] + additional_dependencies: [tomli] # needed to read pyproject.toml below py3.11 exclude: src/pymatgen/analysis/aflow_prototypes.json - repo: https://github.com/MarcoGorelli/cython-lint rev: v0.16.2 hooks: - id: cython-lint - args: [ --no-pycodestyle ] + args: [--no-pycodestyle] - id: double-quote-cython-strings - repo: https://github.com/adamchainz/blacken-docs @@ -56,15 +57,15 @@ repos: # MD033: no inline HTML # MD041: first line in a file should be a top-level heading # MD025: single title - args: [ --disable, MD013, MD024, MD025, MD033, MD041, "--" ] + args: [--disable, MD013, MD024, MD025, MD033, MD041, "--"] - repo: https://github.com/kynan/nbstripout rev: 0.7.1 hooks: - id: nbstripout - args: [ --drop-empty-cells, --keep-output ] + args: [--drop-empty-cells, --keep-output] - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.369 + rev: v1.1.374 hooks: - id: pyright diff --git a/dev_scripts/chemenv/explicit_permutations.py b/dev_scripts/chemenv/explicit_permutations.py index 097e80b25e0..f3225fa5293 100644 --- a/dev_scripts/chemenv/explicit_permutations.py +++ b/dev_scripts/chemenv/explicit_permutations.py @@ -10,6 +10,7 @@ import os import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import ( AllCoordinationGeometries, ExplicitPermutationsAlgorithm, diff --git a/dev_scripts/chemenv/explicit_permutations_plane_algorithm.py b/dev_scripts/chemenv/explicit_permutations_plane_algorithm.py index 689ae58d86a..bd71080c300 100644 --- a/dev_scripts/chemenv/explicit_permutations_plane_algorithm.py +++ b/dev_scripts/chemenv/explicit_permutations_plane_algorithm.py @@ -9,6 +9,7 @@ import json import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import AllCoordinationGeometries from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import ( AbstractGeometry, diff --git a/dev_scripts/chemenv/get_plane_permutations_optimized.py b/dev_scripts/chemenv/get_plane_permutations_optimized.py index 127ca009f19..1244d13e487 100644 --- a/dev_scripts/chemenv/get_plane_permutations_optimized.py +++ b/dev_scripts/chemenv/get_plane_permutations_optimized.py @@ -15,6 +15,7 @@ import numpy as np import tabulate + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import AllCoordinationGeometries from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import ( AbstractGeometry, diff --git a/dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py b/dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py index 70449d924f8..5709df6317a 100644 --- a/dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py +++ b/dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py @@ -8,6 +8,7 @@ import matplotlib.pyplot as plt import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import ( AngleNbSetWeight, CNBiasNbSetWeight, @@ -50,7 +51,9 @@ def __init__(self, initial_environment_symbol, expected_final_environment_symbol self.abstract_geometry = AbstractGeometry.from_cg(self.coordination_geometry) @classmethod - def simple_expansion(cls, initial_environment_symbol, expected_final_environment_symbol, neighbors_indices): + def simple_expansion( + cls, initial_environment_symbol, expected_final_environment_symbol, neighbors_indices + ) -> CoordinationEnvironmentMorphing: """Simple expansion of a coordination environment. Args: diff --git a/dev_scripts/chemenv/test_algos.py b/dev_scripts/chemenv/test_algos.py index 17933a067a3..dbffdce27e5 100644 --- a/dev_scripts/chemenv/test_algos.py +++ b/dev_scripts/chemenv/test_algos.py @@ -8,6 +8,7 @@ from random import shuffle import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import AllCoordinationGeometries from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import ( AbstractGeometry, diff --git a/dev_scripts/chemenv/view_environment.py b/dev_scripts/chemenv/view_environment.py index 69aa6adc42e..2caa22e9f34 100644 --- a/dev_scripts/chemenv/view_environment.py +++ b/dev_scripts/chemenv/view_environment.py @@ -3,6 +3,7 @@ from __future__ import annotations import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import ( SEPARATION_PLANE, AllCoordinationGeometries, diff --git a/dev_scripts/potcar_scrambler.py b/dev_scripts/potcar_scrambler.py index c0793c713d9..0cf09dc5b77 100644 --- a/dev_scripts/potcar_scrambler.py +++ b/dev_scripts/potcar_scrambler.py @@ -9,6 +9,7 @@ import numpy as np from monty.os.path import zpath from monty.serialization import zopen + from pymatgen.core import SETTINGS from pymatgen.io.vasp import Potcar, PotcarSingle from pymatgen.io.vasp.sets import _load_yaml_config @@ -47,20 +48,21 @@ def __init__(self, potcars: Potcar | PotcarSingle) -> None: def _rand_float_from_str_with_prec(self, input_str: str, bloat: float = 1.5) -> float: n_prec = len(input_str.split(".")[1]) bd = max(1, bloat * abs(float(input_str))) # ensure we don't get 0 - return round(bd * np.random.rand(1)[0], n_prec) + return round(bd * np.random.default_rng().random(), n_prec) def _read_fortran_str_and_scramble(self, input_str: str, bloat: float = 1.5): input_str = input_str.strip() + rng = np.random.default_rng() if input_str.lower() in {"t", "f", "true", "false"}: - return bool(np.random.randint(2)) + return rng.choice((True, False)) if input_str.upper() == input_str.lower() and input_str[0].isnumeric(): if "." in input_str: return self._rand_float_from_str_with_prec(input_str, bloat=bloat) integer = int(input_str) fac = int(np.sign(integer)) # return int of same sign - return fac * np.random.randint(abs(max(1, int(np.ceil(bloat * integer))))) + return fac * rng.integers(abs(max(1, int(np.ceil(bloat * integer))))) try: float(input_str) return self._rand_float_from_str_with_prec(input_str, bloat=bloat) diff --git a/dev_scripts/update_pt_data.py b/dev_scripts/update_pt_data.py index ee7889c75ea..88f321ed712 100644 --- a/dev_scripts/update_pt_data.py +++ b/dev_scripts/update_pt_data.py @@ -11,9 +11,10 @@ import requests from monty.dev import requires from monty.serialization import dumpfn, loadfn -from pymatgen.core import Element, get_el_sp from ruamel import yaml +from pymatgen.core import Element, get_el_sp + try: from bs4 import BeautifulSoup except ImportError: diff --git a/dev_scripts/update_spacegroup_data.py b/dev_scripts/update_spacegroup_data.py index a4607cdbee7..07cd5d66344 100644 --- a/dev_scripts/update_spacegroup_data.py +++ b/dev_scripts/update_spacegroup_data.py @@ -12,6 +12,7 @@ import sys from monty.serialization import dumpfn, loadfn + from pymatgen.symmetry.groups import PointGroup __author__ = "Katharina Ueltzen @kaueltzen" @@ -29,7 +30,7 @@ def convert_symmops_to_sg_encoding(symbol: str) -> str: Args: symbol (str): "hermann_mauguin" or "universal_h_m" key of symmops.json Returns: - symbol in the format of SYMM_DATA["space_group_encoding"] keys + str: symbol in the format of SYMM_DATA["space_group_encoding"] keys """ symbol_representation = symbol.split(":") representation = ":" + "".join(symbol_representation[1].split(" ")) if len(symbol_representation) > 1 else "" @@ -50,7 +51,7 @@ def remove_identity_from_full_hermann_mauguin(symbol: str) -> str: Args: symbol (str): "hermann_mauguin" key of symmops.json Returns: - short "hermann_mauguin" key + str: short "hermann_mauguin" key """ if symbol in ("P 1", "C 1", "P 1 "): return symbol diff --git a/docs/CHANGES.md b/docs/CHANGES.md index 6b162785e8e..b080903b763 100644 --- a/docs/CHANGES.md +++ b/docs/CHANGES.md @@ -6,6 +6,14 @@ nav_order: 4 # Changelog +## v2024.7.18 +- Fix `setuptools` for packaging (#3934) +- Improve Keep Redundant Spaces algorithm for PatchedPhaseDiagram (#3900) +- Add electronic structure methods for Species (#3902) +- Migrate `spglib` to new `SpglibDataset` format with version 2.5.0 (#3923) +- SpaceGroup changes (#3859) +- Add MD input set to FHI-aims (#3896) + ## v2024.6.10 * Fix bug in `update_charge_from_potcar` (#3866) * Fix bug in VASP parameter parsing (@mkhorton) diff --git a/docs/modules.html b/docs/modules.html index 8176ffd9a89..45c32066fbe 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -305,15 +305,7 @@

pymatgen
  • pymatgen.analysis.solar package
  • pymatgen.analysis.structure_prediction package
  • pymatgen.io.aims.outputs module