Skip to content

Commit ad6b7eb

Browse files
authored
Merge pull request #130 from materialsproject/chores/pre-commit
[Chores] pre-commit + docs
2 parents 43351ff + a6d751f commit ad6b7eb

File tree

9 files changed

+83
-117
lines changed

9 files changed

+83
-117
lines changed

.github/workflows/python-publish.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ jobs:
2222

2323
steps:
2424
- uses: actions/checkout@v4
25+
- uses: astral-sh/setup-uv@v5
2526
- name: Set up Python
2627
uses: actions/setup-python@v5
2728
with:
28-
python-version: '3.11'
29-
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
pip install build
29+
python-version: '3.13'
3330
- name: Build package
34-
run: python -m build
31+
run: uv build
3532
- name: >-
3633
Publish Python 🐍 distribution 📦 to PyPI
3734
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/testing.yml

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,60 @@
1+
name: Testing
2+
13
on:
24
push:
35
branches:
46
- main
57
tags:
6-
- 'v*'
8+
- "v*"
79
pull_request:
810
branches:
911
- main
12+
1013
jobs:
1114
lint:
1215
runs-on: ubuntu-latest
1316

1417
steps:
1518
- uses: actions/checkout@v4
19+
- uses: astral-sh/setup-uv@v5
1620
- uses: actions/setup-python@v5
1721
with:
18-
python-version: "3.11"
19-
cache: pip
20-
cache-dependency-path: pyproject.toml
22+
python-version: "3.13"
2123

2224
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install .[tests,dev]
25+
run: uv pip install --system .[tests,dev]
2626

2727
- name: Lint
28-
run: |
29-
pre-commit run --all-files --show-diff-on-failure
28+
run: pre-commit run --all-files --show-diff-on-failure
3029

3130
test:
3231
runs-on: ubuntu-latest
3332
strategy:
3433
matrix:
35-
python-version: ["3.10", "3.11", "3.12"]
34+
python-version: ["3.10", "3.11", "3.12", "3.13"]
3635

3736
steps:
38-
- uses: actions/checkout@v4
39-
40-
- uses: actions/setup-python@v5
41-
with:
42-
python-version: ${{ matrix.python-version }}
43-
44-
- uses: actions/cache@v2
45-
with:
46-
path: ~/.cache/pip
47-
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('**/setup.py') }}
48-
restore-keys: |
49-
${{ runner.os }}-${{ matrix.python-version }}-pip-
50-
51-
- name: Install dependencies
52-
run: |
53-
python -m pip install --upgrade pip
54-
pip install .[tests]
55-
56-
- name: Test
57-
run: |
58-
pytest --cov=pyrho --cov-report=xml
59-
60-
- uses: codecov/codecov-action@v1
61-
if: matrix.python-version == 3.11
62-
with:
63-
token: ${{ secrets.CODECOV_TOKEN }}
64-
file: ./coverage.xml
37+
- uses: actions/checkout@v4
38+
- uses: astral-sh/setup-uv@v5
39+
with:
40+
enable-cache: true
41+
cache-dependency-glob: "pyproject.toml"
42+
43+
- uses: actions/setup-python@v5
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
47+
- name: Install dependencies
48+
run: uv pip install --system .[tests]
49+
50+
- name: Test
51+
run: pytest --cov=pyrho --cov-report=xml
52+
53+
- uses: codecov/codecov-action@v4
54+
if: matrix.python-version == 3.13
55+
with:
56+
token: ${{ secrets.CODECOV_TOKEN }}
57+
files: ./coverage.xml
6558

6659
docs:
6760
runs-on: ubuntu-latest
@@ -72,14 +65,18 @@ jobs:
7265
- name: Install pandoc
7366
run: sudo apt-get install pandoc
7467

68+
- uses: astral-sh/setup-uv@v5
69+
with:
70+
enable-cache: true
71+
cache-dependency-glob: "pyproject.toml"
72+
7573
- uses: actions/setup-python@v5
7674
with:
77-
python-version: 3.11
75+
python-version: 3.13
7876

7977
- name: Install dependencies
80-
run: |
81-
python -m pip install --upgrade pip lxml[html_clean]
82-
pip install -e .[docs]
78+
run: uv pip install --system -e .[docs]
79+
8380
- name: Build
8481
run: sphinx-build docs/source _build
8582

.github/workflows/update-precommit.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,30 @@ on:
44
schedule:
55
- cron: '0 0 1,14,28 * *'
66

7+
permissions:
8+
contents: write
9+
pull-requests: write
710

811
jobs:
912
auto-update:
1013
runs-on: ubuntu-latest
1114
steps:
12-
- uses: actions/checkout@v2.3.4
15+
- uses: actions/checkout@v4
16+
- uses: astral-sh/setup-uv@v5
1317

1418
- name: Set up Python
15-
uses: actions/setup-python@v2.2.2
19+
uses: actions/setup-python@v5
1620
with:
17-
python-version: 3.8
21+
python-version: 3.13
1822

1923
- name: Install pre-commit
20-
run: pip install pre-commit
24+
run: uv pip install --system pre-commit
2125

2226
- name: Run pre-commit autoupdate
2327
run: pre-commit autoupdate
2428

2529
- name: Create Pull Request
26-
uses: peter-evans/create-pull-request@v3
30+
uses: peter-evans/create-pull-request@v7
2731
with:
2832
branch: update/pre-commit-autoupdate
2933
title: Auto-update pre-commit hooks

.pre-commit-config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
default_language_version:
22
python: python3
3+
exclude: ^notebooks/
34
repos:
45
- repo: https://github.com/astral-sh/ruff-pre-commit
56
# Ruff version.
6-
rev: v0.1.8
7+
rev: v0.13.3
78
hooks:
89
# Run the linter.
9-
- id: ruff
10+
- id: ruff-check
1011
args: [ --fix ]
1112
# Run the formatter.
1213
- id: ruff-format
1314
- repo: https://github.com/pre-commit/mirrors-mypy
14-
rev: v1.5.1
15+
rev: v1.18.2
1516
hooks:
1617
- id: mypy
1718
files: ^src/
@@ -22,7 +23,7 @@ repos:
2223
- tokenize-rt==4.1.0
2324
- types-pkg_resources==0.1.2
2425
- repo: https://github.com/codespell-project/codespell
25-
rev: v2.2.6
26+
rev: v2.4.1
2627
hooks:
2728
- id: codespell
2829
name: codespell

mkdocs.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

pyproject.toml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@ requires-python = ">=3.9"
3030
[tool.setuptools_scm]
3131

3232
[project.optional-dependencies]
33-
dev = ["pre-commit==3.6.2"]
33+
dev = ["pre-commit==4.3.0"]
3434
docs = [
35-
"numpydoc==1.6.0",
36-
"sphinx==7.2.6",
37-
"furo==2024.1.29",
38-
"m2r2==v0.3.3.post2",
39-
"ipython==8.4.0",
40-
"nbsphinx==0.8.9",
41-
"nbsphinx-link==1.3.0",
42-
"sphinx-autodoc-typehints==2.0.0",
43-
"sphinx-autoapi==3.0.0",
35+
"numpydoc==1.9.0",
36+
"sphinx==8.2.3",
37+
"furo==2025.9.25",
38+
"m2r2==0.3.4",
39+
"ipython==9.6.0",
40+
"nbsphinx==0.9.6",
41+
"nbsphinx-link==1.3.1",
42+
"sphinx-autodoc-typehints==3.5.1",
43+
"sphinx-autoapi==3.6.1",
44+
"lxml_html_clean==0.4.3",
4445
]
4546
tests = [
4647
"pytest>=7.1.2",

src/pyrho/charge_density.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Chang Density Objects: Periodic Grid + Lattice / Atoms."""
2+
23
from __future__ import annotations
34

45
import math
@@ -232,7 +233,7 @@ def get_transformed(
232233
if isinstance(grid_out, int):
233234
ngrid = grid_out / new_structure.volume
234235
mult = (np.prod(lengths) / ngrid) ** (1 / 3)
235-
grid_out = [int(math.floor(max(l_ / mult, 1))) for l_ in lengths]
236+
grid_out = [math.floor(max(l_ / mult, 1)) for l_ in lengths]
236237

237238
pgrids = {}
238239
for k, pgrid in self.normalized_pgrids.items():
@@ -436,18 +437,18 @@ def multiply_aug(data_aug: list[str], factor: int) -> list[str]:
436437
if cur_block:
437438
for _ in range(factor):
438439
cnt += 1
439-
cur_block[
440-
0
441-
] = f"augmentation occupancies{cnt:>4}{cur_block[0].split()[-1]:>4}\n"
440+
cur_block[0] = (
441+
f"augmentation occupancies{cnt:>4}{cur_block[0].split()[-1]:>4}\n"
442+
)
442443
res.extend(cur_block)
443444
cur_block = [ll]
444445
else:
445446
cur_block.append(ll)
446447
for _ in range(factor):
447448
cnt += 1
448-
cur_block[
449-
0
450-
] = f"augmentation occupancies{cnt:>4}{cur_block[0].split()[-1]:>4}\n"
449+
cur_block[0] = (
450+
f"augmentation occupancies{cnt:>4}{cur_block[0].split()[-1]:>4}\n"
451+
)
451452
res.extend(cur_block)
452453
return res
453454

src/pyrho/utils.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Util Functions."""
2+
23
from __future__ import annotations
34

45
from itertools import combinations
@@ -12,15 +13,15 @@
1213
from numpy.typing import ArrayLike, NDArray
1314

1415
__all__ = [
15-
"pad_arr",
16-
"interpolate_fourier",
17-
"roll_array",
18-
"get_sc_interp",
16+
"gaussian_smear",
1917
"get_padded_array",
2018
"get_plane_spacing",
19+
"get_sc_interp",
2120
"get_ucell_frac_fit_sphere",
2221
"get_ucell_frac_fit_sphere",
23-
"gaussian_smear",
22+
"interpolate_fourier",
23+
"pad_arr",
24+
"roll_array",
2425
]
2526

2627

@@ -75,7 +76,7 @@ def get_slice(idig, idim, bound_pairs):
7576
for i_dim, j_dim in zip(dimensions, shape)
7677
]
7778
dim = len(dimensions)
78-
fmt = f"#0{dim+2}b"
79+
fmt = f"#0{dim + 2}b"
7980
corners = [format(itr, fmt)[-dim:] for itr in range(2**dim)]
8081
arr_out = np.zeros(shape, dtype=arr_in.dtype)
8182

@@ -291,7 +292,7 @@ def get_plane_spacing(lattice: NDArray) -> List[float]:
291292
if j != idir
292293
]
293294
v_perp_subspace = lattice[idir] - sum(idir_proj)
294-
spacing.append(np.linalg.norm(v_perp_subspace))
295+
spacing.append(float(np.linalg.norm(v_perp_subspace)))
295296
return spacing
296297

297298

src/pyrho/vis/scatter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Helper functions to visualize the data in plotly."""
2+
23
from __future__ import annotations
34

45
from typing import TYPE_CHECKING

0 commit comments

Comments
 (0)