Skip to content

Commit 11461e1

Browse files
authored
Add ruff checks (pyscf#172)
* Add ruff checks * Fix actions * warnings from ruff
1 parent cdf9a7d commit 11461e1

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

.github/workflows/lint.yml

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ name: Lint
33
on: [push, pull_request]
44

55
jobs:
6+
ruff:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v4
11+
- name: Install ruff
12+
run: pip install ruff
13+
- name: Check style
14+
run: ruff check --config .ruff.toml gpu4pyscf
15+
- name: Check NumPy
16+
run: ruff check --select NPY --ignore NPY002 gpu4pyscf
617
flake:
718
runs-on: ubuntu-latest
819
steps:

.ruff.toml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
exclude = [
2+
"test",
3+
]
4+
5+
respect-gitignore = true
6+
line-length = 120
7+
8+
[lint]
9+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
10+
#select = ["E4", "E7", "E9", "F"]
11+
ignore = [
12+
# Whitespaces:
13+
"E201", "E202", "E203", "E211", "E221", "E222", "E225", "E226", "E228", "E231", "E241", "E251",
14+
# Comments:
15+
"E261", "E262", "E265", "E266",
16+
# Blank lines:
17+
"E301", "E302", "E303", "E305", "E306",
18+
# Imports:
19+
"E401", "E402",
20+
# Other:
21+
"E701", "E713", "E721", "E731", "E741", "E275",
22+
"F401", "F403", "C901", "W391"
23+
]
24+
25+
[format]
26+
# Like Black, indent with spaces, rather than tabs.
27+
indent-style = "space"
28+
29+
# Like Black, automatically detect the appropriate line ending.
30+
line-ending = "auto"
31+
32+
quote-style = "single"

gpu4pyscf/dft/xc_alias.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@
2424
'PBE0' : 'HYB_GGA_XC_PBEH',
2525
'WB97' : 'HYB_GGA_XC_WB97',
2626
'WB97X' : 'HYB_GGA_XC_WB97X',
27-
'CAMB3LYP' : 'HYB_GGA_XC_CAM_B3LYP',
28-
'CAMYBLYP' : 'HYB_GGA_XC_CAMY_BLYP',
29-
'CAMYB3LYP' : 'HYB_GGA_XC_CAMY_B3LYP',
30-
}
27+
}

gpu4pyscf/solvent/tests/test_pcm.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_to_gpu(self):
142142
assert abs(e_cpu - e_gpu) < 1e-8
143143

144144
@pytest.mark.skipif(pyscf_25, reason='requires pyscf 2.6 or higher')
145-
def test_to_cpu(self):
145+
def test_to_cpu_1(self):
146146
mf = dft.RKS(mol, xc='b3lyp').PCM()
147147
e_gpu = mf.kernel()
148148
mf = mf.to_cpu()
@@ -154,6 +154,7 @@ def test_to_cpu(self):
154154
mf = mf.to_cpu()
155155
e_cpu = mf.kernel()
156156
assert abs(e_cpu - e_gpu) < 1e-8
157+
157158
if __name__ == "__main__":
158159
print("Full Tests for PCMs")
159160
unittest.main()

0 commit comments

Comments
 (0)