Skip to content

Commit

Permalink
Merge branch 'master' into aims_control_in_None_value_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tpurcell90 authored Mar 29, 2024
2 parents 8c8361a + 8e6acdd commit 61f8c1f
Show file tree
Hide file tree
Showing 400 changed files with 23,994 additions and 14,983 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]
workflow_dispatch: # enable manual workflow execution

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
Expand All @@ -22,25 +18,26 @@ concurrency:
cancel-in-progress: false

jobs:
# Build job
build:
# prevent this action from running on forks
if: github.repository == 'materialsproject/pymatgen'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./docs
destination: ./_site

- name: Upload artifact
uses: actions/upload-pages-artifact@v2

# Deployment job
deploy:
environment:
name: github-pages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: ruff
run: |
ruff --version
ruff .
ruff check .
ruff format --check .
- name: mypy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
uv pip install -e '.[dev,optional]' --system
# TODO remove next line installing ase from main branch when FrechetCellFilter is released
uv pip install --upgrade 'ase@git+https://gitlab.com/ase/ase' --system
uv pip install --upgrade 'git+https://gitlab.com/ase/ase' --system
- name: pytest split ${{ matrix.split }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
rev: v0.3.4
hooks:
- id: ruff
args: [--fix, --unsafe-fixes]
Expand Down
2 changes: 1 addition & 1 deletion dev_scripts/chemenv/get_plane_permutations_optimized.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def random_permutations_iterator(initial_permutation, n_permutations):
f"Get the explicit optimized permutations for geometry {cg.name!r} (symbol : "
f'{cg_symbol!r}) ? ("y" to confirm, "q" to quit)\n'
)
if test not in ["y", "q"]:
if test not in ("y", "q"):
print("Wrong key, try again")
continue
if test == "y":
Expand Down
26 changes: 13 additions & 13 deletions dev_scripts/potcar_scrambler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import warnings
from glob import glob
from typing import TYPE_CHECKING

import numpy as np
from monty.os.path import zpath
Expand All @@ -14,6 +15,9 @@
from pymatgen.io.vasp.sets import _load_yaml_config
from pymatgen.util.testing import VASP_IN_DIR

if TYPE_CHECKING:
from typing_extensions import Self


class PotcarScrambler:
"""
Expand All @@ -34,26 +38,22 @@ class PotcarScrambler:
from existing POTCAR `input_filename`
"""

def __init__(self, potcars: Potcar | PotcarSingle):
if isinstance(potcars, PotcarSingle):
self.PSP_list = [potcars]
else:
self.PSP_list = potcars
def __init__(self, potcars: Potcar | PotcarSingle) -> None:
self.PSP_list = [potcars] if isinstance(potcars, PotcarSingle) else potcars
self.scrambled_potcars_str = ""
for psp in self.PSP_list:
scrambled_potcar_str = self.scramble_single_potcar(psp)
self.scrambled_potcars_str += scrambled_potcar_str
return

def _rand_float_from_str_with_prec(self, input_str: str, bloat: float = 1.5):
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)))
return round(bd * np.random.rand(1)[0], n_prec)

def _read_fortran_str_and_scramble(self, input_str: str, bloat: float = 1.5):
input_str = input_str.strip()

if input_str.lower() in ("t", "f", "true", "false"):
if input_str.lower() in {"t", "f", "true", "false"}:
return bool(np.random.randint(2))

if input_str.upper() == input_str.lower() and input_str[0].isnumeric():
Expand All @@ -68,7 +68,7 @@ def _read_fortran_str_and_scramble(self, input_str: str, bloat: float = 1.5):
except ValueError:
return input_str

def scramble_single_potcar(self, potcar: PotcarSingle):
def scramble_single_potcar(self, potcar: PotcarSingle) -> str:
"""
Scramble the body of a POTCAR, retain the PSCTR header information.
Expand Down Expand Up @@ -124,20 +124,20 @@ def scramble_single_potcar(self, potcar: PotcarSingle):
)
return scrambled_potcar_str

def to_file(self, filename: str):
def to_file(self, filename: str) -> None:
with zopen(filename, mode="wt") as file:
file.write(self.scrambled_potcars_str)

@classmethod
def from_file(cls, input_filename: str, output_filename: str | None = None):
def from_file(cls, input_filename: str, output_filename: str | None = None) -> Self:
psp = Potcar.from_file(input_filename)
psp_scrambled = cls(psp)
if output_filename:
psp_scrambled.to_file(output_filename)
return psp_scrambled


def generate_fake_potcar_libraries():
def generate_fake_potcar_libraries() -> None:
"""
To test the `_gen_potcar_summary_stats` function in `pymatgen.io.vasp.inputs`,
need a library of fake POTCARs which do not violate copyright
Expand Down Expand Up @@ -173,7 +173,7 @@ def generate_fake_potcar_libraries():
break


def potcar_cleanser():
def potcar_cleanser() -> None:
"""
Function to replace copyrighted POTCARs used in io.vasp.sets testing
with dummy POTCARs that have scrambled PSP and kinetic energy values
Expand Down
12 changes: 6 additions & 6 deletions dev_scripts/regen_libxcfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ def write_libxc_docs_json(xc_funcs, json_path):
xc_funcs = deepcopy(xc_funcs)

# Remove XC_FAMILY from Family and XC_ from Kind to make strings more human-readable.
for d in xc_funcs.values():
d["Family"] = d["Family"].replace("XC_FAMILY_", "", 1)
d["Kind"] = d["Kind"].replace("XC_", "", 1)
for dct in xc_funcs.values():
dct["Family"] = dct["Family"].replace("XC_FAMILY_", "", 1)
dct["Kind"] = dct["Kind"].replace("XC_", "", 1)

# Build lightweight version with a subset of keys.
for num, d in xc_funcs.items():
xc_funcs[num] = {key: d[key] for key in ("Family", "Kind", "References")}
for num, dct in xc_funcs.items():
xc_funcs[num] = {key: dct[key] for key in ("Family", "Kind", "References")}
# Descriptions are optional
for opt in ("Description 1", "Description 2"):
desc = d.get(opt)
desc = dct.get(opt)
if desc is not None:
xc_funcs[num][opt] = desc

Expand Down
23 changes: 11 additions & 12 deletions dev_scripts/update_pt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ def parse_radii():
def update_ionic_radii():
data = loadfn(ptable_yaml_path)

for d in data.values():
if "Ionic_radii" in d:
d["Ionic radii"] = {k: v / 100 for k, v in d["Ionic_radii"].items()}
del d["Ionic_radii"]
if "Ionic_radii_hs" in d:
d["Ionic radii hs"] = {k: v / 100 for k, v in d["Ionic_radii_hs"].items()}
del d["Ionic_radii_hs"]
if "Ionic_radii_ls" in d:
d["Ionic radii ls"] = {k: v / 100 for k, v in d["Ionic_radii_ls"].items()}
del d["Ionic_radii_ls"]
for dct in data.values():
if "Ionic_radii" in dct:
dct["Ionic radii"] = {k: v / 100 for k, v in dct["Ionic_radii"].items()}
del dct["Ionic_radii"]
if "Ionic_radii_hs" in dct:
dct["Ionic radii hs"] = {k: v / 100 for k, v in dct["Ionic_radii_hs"].items()}
del dct["Ionic_radii_hs"]
if "Ionic_radii_ls" in dct:
dct["Ionic radii ls"] = {k: v / 100 for k, v in dct["Ionic_radii_ls"].items()}
del dct["Ionic_radii_ls"]
with open("periodic_table2.yaml", mode="w") as file:
yaml.dump(data, file)
with open("../pymatgen/core/periodic_table.json", mode="w") as file:
Expand All @@ -162,8 +162,7 @@ def parse_shannon_radii():
radii[el][charge] = {}
if sheet[f"C{i}"].value:
cn = sheet[f"C{i}"].value
if cn not in radii[el][charge]:
radii[el][charge][cn] = {}
radii[el][charge].setdefault(cn, {})

spin = sheet[f"D{i}"].value if sheet[f"D{i}"].value is not None else ""

Expand Down
8 changes: 8 additions & 0 deletions docs/apidoc/pymatgen.io.aims.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions docs/apidoc/pymatgen.io.aims.sets.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/apidoc/pymatgen.io.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions docs/apidoc/pymatgen.util.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions docs/apidoc/pymatgen.util.testing.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 61f8c1f

Please sign in to comment.