Skip to content

Commit d195474

Browse files
authored
Merge branch 'materialsproject:master' into fix_icohp
2 parents 5646066 + 1b8c5f8 commit d195474

File tree

91 files changed

+9124
-8784
lines changed

Some content is hidden

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

91 files changed

+9124
-8784
lines changed

.pre-commit-config.yaml

+4-4
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.9.2
11+
rev: v0.9.4
1212
hooks:
1313
- id: ruff
1414
args: [--fix, --unsafe-fixes]
@@ -27,7 +27,7 @@ repos:
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
3333
stages: [pre-commit, commit-msg]
@@ -48,7 +48,7 @@ repos:
4848
- id: blacken-docs
4949

5050
- repo: https://github.com/igorshubovych/markdownlint-cli
51-
rev: v0.43.0
51+
rev: v0.44.0
5252
hooks:
5353
- id: markdownlint
5454
# MD013: line too long
@@ -65,6 +65,6 @@ repos:
6565
args: [--drop-empty-cells, --keep-output]
6666

6767
- repo: https://github.com/RobertCraigie/pyright-python
68-
rev: v1.1.391
68+
rev: v1.1.393
6969
hooks:
7070
- id: pyright

dev_scripts/potcar_scrambler.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class PotcarScrambler:
2323
"""
24-
Takes a POTCAR and replaces its values with completely random values
24+
Takes a POTCAR and replaces its values with completely random values.
2525
Does type matching and attempts precision matching on floats to ensure
2626
file is read correctly by Potcar and PotcarSingle classes.
2727
@@ -40,14 +40,15 @@ class PotcarScrambler:
4040

4141
def __init__(self, potcars: Potcar | PotcarSingle) -> None:
4242
self.PSP_list = [potcars] if isinstance(potcars, PotcarSingle) else potcars
43-
self.scrambled_potcars_str = ""
43+
self.scrambled_potcars_str: str = ""
4444
for psp in self.PSP_list:
4545
scrambled_potcar_str = self.scramble_single_potcar(psp)
4646
self.scrambled_potcars_str += scrambled_potcar_str
4747

4848
def _rand_float_from_str_with_prec(self, input_str: str, bloat: float = 1.5) -> float:
49-
n_prec = len(input_str.split(".")[1])
50-
bd = max(1, bloat * abs(float(input_str))) # ensure we don't get 0
49+
"""Generate a random float from str to replace true values."""
50+
n_prec: int = len(input_str.split(".")[1])
51+
bd: float = max(1.0, bloat * abs(float(input_str))) # ensure we don't get 0
5152
return round(bd * np.random.default_rng().random(), n_prec)
5253

5354
def _read_fortran_str_and_scramble(self, input_str: str, bloat: float = 1.5):
@@ -124,14 +125,16 @@ def scramble_single_potcar(self, potcar: PotcarSingle) -> str:
124125
return scrambled_potcar_str
125126

126127
def to_file(self, filename: str) -> None:
128+
"""Write scrambled POTCAR to file."""
127129
with zopen(filename, mode="wt", encoding="utf-8") as file:
128130
file.write(self.scrambled_potcars_str)
129131

130132
@classmethod
131133
def from_file(cls, input_filename: str, output_filename: str | None = None) -> Self:
134+
"""Read a POTCAR from file and generate a scrambled version."""
132135
psp = Potcar.from_file(input_filename)
133136
psp_scrambled = cls(psp)
134-
if output_filename:
137+
if output_filename is not None:
135138
psp_scrambled.to_file(output_filename)
136139
return psp_scrambled
137140

docs/CHANGES.md

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/modules.html

+13-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)